Command Line
-
I'm trying to send commands from my C# project to the command line. The cmd is opening but the arguments are not being passed. Here is my code: System.Diagnostics.ProcessStartInfo psi = null; System.Diagnostics.Process proc = null; psi = new System.Diagnostics.ProcessStartInfo("cmd"); proc = new System.Diagnostics.Process(); proc.StartInfo = psi; System.Diagnostics.Process.Start(psi); psi.Arguments = @"ping dev12"; Application.DoEvents(); System.Diagnostics.Process.Start(psi); proc.WaitForExit(); Thanks.
-
I'm trying to send commands from my C# project to the command line. The cmd is opening but the arguments are not being passed. Here is my code: System.Diagnostics.ProcessStartInfo psi = null; System.Diagnostics.Process proc = null; psi = new System.Diagnostics.ProcessStartInfo("cmd"); proc = new System.Diagnostics.Process(); proc.StartInfo = psi; System.Diagnostics.Process.Start(psi); psi.Arguments = @"ping dev12"; Application.DoEvents(); System.Diagnostics.Process.Start(psi); proc.WaitForExit(); Thanks.
The argument ARE being passed. You're just not supplying the correct arguments to CMD. The command line your passing in is this:
cmd ping dev12
Try typing that in a Start/Run box and watch what happens. What you should be passing in is:
cmd /c ping dev12
The "/C" tells CMD to execute the following string and a command, then terminate when that command is done. "/K" will tell CMD to remain open after the command it execute returns. All you have to do to find this out is type "CMD /?" at a command prompt. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome