Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Command Prompt from closing so quickly

I'm trying to troubleshoot why the following function isn't working.

 public void RunCmd()
            {
                string strCmdText;
                strCmdText = "/C [enter command stuff here]";
                System.Diagnostics.Process.Start("CMD.exe", strCmdText);
            }

However whenever I try to run it or throw in some breakpoints, command opens, shows an error, and then closes really quickly (so quickly that I can't read anything).

Is there a way I can halt the program or figure out what's going on? Breakpoints don't seem to be working.

When I directly type it in Command Prompt instead of running it via this c# script, it the command works fine.

like image 995
sir_thursday Avatar asked Dec 02 '22 18:12

sir_thursday


2 Answers

try this:

 strCmdText = "/K [enter command stuff here]";

/C Carries out the command specified by string and then terminates

/K Carries out the command specified by string but remains

like image 186
traxs Avatar answered Dec 04 '22 07:12

traxs


Maybe try adding a pause command?

like image 44
Michael Lawton Avatar answered Dec 04 '22 08:12

Michael Lawton