6

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 :)

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Goondude
  • 101
  • 1
  • 3
  • 10

2 Answers2

6

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

Riv
  • 1,849
  • 1
  • 16
  • 16
4

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

keyboardP
  • 68,824
  • 13
  • 156
  • 205