This is my code
System.Diagnostics.ProcessStartInfo proc = new System.Diagnostics.ProcessStartInfo();
proc.FileName = @"cmd.exe";
proc.Arguments = "/C "+ "ipconfig" ;
System.Diagnostics.Process.Start(proc);
when I run this code , Cmd run and shut down so quickly . How to pause it ?
THANKS A LOT :)
Execution of a batch script can also be paused by pressing CTRL-S (or the Pause|Break key) on the keyboard, this also works for pausing a single command such as a long DIR /s listing.
The pause command is used within a computer batch file. It allows the computer to pause the currently running batch file until the user presses any key.
The ECHO-OFF command suppresses echoing for the terminal attached to a specified process. The ECHO-ON command restores input echoing for a specified process. These commands are frequently used in Procs.
Specify the K parameter instead of C
From Microsoft documentation:
/c : Carries out the command specified by string and then stops.
/k : Carries out the command specified by string and continues.
proc.Arguments = "/K "+ "ipconfig" ;
more info: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true
Use /K
instead of /C
.
proc.Arguments = "/K " + "ipconfig";
You can see a list of command line switches here
/C Run Command and then terminate
/K Run Command and then return to the CMD prompt. This is useful for testing, to examine variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With