Search code examples
filebatch-filecmd

Keep CMD open after BAT file executes


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 itself.

I believe that CMD assumes the script has finished, so it closes.

How do I keep CMD open after the script is finished?


Solution

  • Depending on how you are running the command, you can put /k after cmd to keep the window open.

    cmd /k my_script.bat
    

    Simply adding cmd /k to the end of your batch file will work too. Credit to Luigi D'Amico who posted about this in the comments below.