Solved

c# .net how do I convert a console app to be a power shell program?

Posted on 2010-08-12
5
566 Views
Last Modified: 2013-12-17
c# how do I convert a console app to be a power shell program?
0
Comment
Question by:jackjohnson44
  • 4
5 Comments
 
LVL 11

Expert Comment

by:jgordos
ID: 33421079
Is the console application a .net application you wrote?

I mean, is it a C# console application with a main() that has an extension of ".exe"?

-john
0
 

Author Comment

by:jackjohnson44
ID: 33421139
yes, that is correct.  I run it from a dos command line
0
 
LVL 11

Expert Comment

by:jgordos
ID: 33422121
Okay, so here's the question....

Do you just want to run the existing program?

Or

Do you want to write PowerShell programs that do the same thing as the existing program, but translated from C# to PowerShell?

-john
0
 
LVL 11

Accepted Solution

by:
jgordos earned 500 total points
ID: 33422270
I mean, if all you want to do is run the program like you do from the command line now, all you have to do is run it... like from a batch file.

i mean...

Pretend you have a .net "Hello World!" console application, and the compiled executable is  called "hello.exe"

All I do is give powershell scripts a full path to the object...

like

I create a wrapper script called "runme.ps1"

the only thing in the file is:

C:\test\hello.exe

And from a command prompt (normal windows command prompt)

powershell .\runme.ps1

And it all runs...

Hope this helps,
-john
0
 
LVL 11

Expert Comment

by:jgordos
ID: 33422280
or, even simplier...

powershell .\hello.exe


-john
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now