I have a bat file like this:
ipconfig
That will print out the ip info to the screen, but before the user can read that info CMD closes it's self.
I believe that CMD assumes the script has finished, so it closes.
How do I keep CMD open after the script is finished? Thanks!
just Add
@pause
at the endExample :
or u can also use :
Put
pause
at the end of your .BAT file.In Windows add '& Pause' to the end of your command in the file.
Adding
pause
in (Windows 7) to the end did not work for mebut adding the
cmd /k
in front of my command did work.Example :
If you are starting the script within the command line, then add
exit /b
to keep CMD openedJust to clarify something that took me a little bit to understand after reading these responses...
You have to type (literally) "cmd /k" followed by your command. I, at first, thought that "cmd" was to be replaced by your command. Not the case!
For instance I was trying to run java command...
It kept the window open so I could see my "System.out.println()" messages.
I hope this clarification saves someone the approximately 3.5 minutes it took me to figure it out.