How do you make the Command Prompt window stay open after running a command?

Ok, I feel foolish asking this, because I knew the answer before. I'm learning how to program Visual C++. The book I have teaches how to write C++ and then goes into detail on writing the GUI part of Visual C++. The book I have walks me through compiling and making an exe file out of a cpp file, and then it says to go to the directory in Explorer and double-click on the exe file. I do this and the Command Prompt comes up for a quick second before closing down. The example in the book shows the output, and obviously the writer has his Command Prompt  configured to pause after executing an exe.

I just want to configure my Command Prompt to do the same thing, so I can at least see the results. I know that the exe I wrote is working, but I'd like to see the output for less than one second.
 I'm not sure how you are coding this. but if its like a normal batch or anything command line related. 

Do the following to use a user defined switch at the end of the script.

To pause a DOS batch file in Windows XP from continuing to the next command, you can use the PAUSE command. Doing so prompts the user with the text:

Press any key to continue . . .

Then the batch file waits for the user to press a key. However, what if you want to pause a batch file and not display anything? Just pipe the results to nul like so:

pause > nul

Since this may not be very useful (how will the user know they need to press a key to continue the batch file?) you should display a different prompt. Issue an ECHO command with your desired prompt, then issue the above pause > nul command.

For example, to pause a Windows XP batch file with the prompt "Press ENTER to execute the command", use the following commands:

echo Press ENTER to execute the command
pause > nul


19 people found this reply helpful


Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.


Question Info

Last updated September 4, 2020 Views 214,468 Applies to: