I was having a hard time with command prompt windows when I created and ran my batch files – they wouldn’t stay open and kept closing before I could see its output.
Then I discovered the PAUSE command – by adding this command to your batch file, you’ll pause the window for as long as you want, keeping it open so that you can read the output it generates!
So if you want your command prompt DOS window to stay open, then use this following piece of code in your batch file:
REM Put your main code here
ECHO Halting operation. Please press enter to continue.
PAUSE>NUL means that the output of PAUSE will be redirected to the NUL device. This command allows you to replace the default PAUSE message with your own, using an ECHO command before it. In this example, the user will see the message “Halting operation. Please press enter to continue.” Once the user presses enter, the command window will close.