How to suspend cmd before closing it?

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 starts and exits so fast. How to pause?

THANKS A LOT:)

+4
source share
2 answers

Specify K instead of C

From the Microsoft documentation:

/ c: Executes the command indicated by the line and then stops.

/ k: Executes the command indicated on the line and continues.

 proc.Arguments = "/K "+ "ipconfig" ; 

Additional information: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true

+5
source

Use /K instead of /C

 proc.Arguments = "/K " + "ipconfig"; 

You can see the list of command line switches here

/ C Run the command and then exit

/ K Run the command, and then return to the CMD prompt. This is useful for testing, for checking variables.

+3
source

Source: https://habr.com/ru/post/1491094/


All Articles