Run command line code form my App...

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hi,

I want to run some command line instructions from within my C# windows forms
application. Basically when the application closes I want to logoff the
session if it was started remotely.

So how do I run text as if I was typing it into the command line?

Tim
 
Tim said:
I want to run some command line instructions from within my C# windows forms
application. Basically when the application closes I want to logoff the
session if it was started remotely.

So how do I run text as if I was typing it into the command line?

See http://www.pobox.com/~skeet/csharp/faq/#process.start for starting
another process. If you need to run commands which are built into the
shell, you'll need to run the shell explicitly.
 
Use the Process class and execute the program you want to run. If it's a
built-in cmd-command you want to run, just start "cmd.exe /c commandname"

The /c tells cmd to terminate when done and the commandname is the internal
command (and optional parameters) you want it to perform.

Arild
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top