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:
@ECHO OFFREM Put your main code here
ECHO Halting operation. Please press enter to continue.
PAUSE>NUL
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.
Similar Posts:
- How To Make and Run Batch Files In Terminal In Mac OSX
- How To Reset The MySQL Root User Password and Privileges
- How To Solve The Problem Of Always Having To Log On To A Network Drive In Windows
- Common Useful UNIX Commands
- How To Create a Stored Procedure using C#, SQL Server 2008, Visual Studio 2008


February 20th, 2008 at 3:04 pm
I leaned elsewhere and slid in farther.
August 7th, 2008 at 4:24 pm
@ECHO OFF
REM Put your main code here
ECHO Halting operation. Please press enter to continue.
PAUSE>NUL
Hi there, trying to do this, but am a novice.
1. what is my main code after REM, and how do I create this batch file and when done how do I enter it.
Easy for you, difficult for me.
Please help
Thanks
Volker
August 24th, 2008 at 11:00 pm
your main code is whatever you need executed. you can create it by renaming a text file from “something.txt” to “yourfile.bat”. And then you can use notepad to edit it like a normal text document
July 9th, 2009 at 7:46 pm
please help! my command prompt wont stay open. whenever i try to open it, it comes up but disappears in after few seconds. i cant write programs because of this.
September 2nd, 2009 at 6:29 pm
Ovie, I think you “cant write programs” for a lot of reasons.