How to keep the command prompt open

Note: I’m not sure how accurate any of this is - it’s just here for my future reference.

If starting the command prompt, use the /k switch:

cmd.exe /k

If you have a batch file (AKA script) and you’d like the command prompt to stay open when it’s finished, try the pause command at the end of the script.

... do stuff ...

pause

On Windows 7 this may not work. You could try these workarounds:

  • Use the call command in front of every command in your script, then use pause at the end.
  • Run the script as an administrator.
  • Create another script in which you use call to call your original script, followed by pause.

References:

How to prevent batch file (.bat) from closing terminal when running commands?

Last modified: 28/02/2013 Tags:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top