Solved

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

Posted on 2010-08-12
5
577 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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