Solved

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

Posted on 2010-08-12
5
582 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 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