471,354 Members | 1,170 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Run command line code form my App...

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
Jan 3 '06 #1
2 8031
Tim <ti*@home.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 3 '06 #2
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

"Tim" <ti*@home.com> wrote in message
news:FH********************@news20.bellglobal.com. ..
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

Jan 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jon Paal | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.