Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep CMD open after BAT file executes

Tags:

batch-file

cmd

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?

like image 738
pattyd Avatar asked Jul 30 '13 20:07

pattyd


People also ask

How do I keep a Command Prompt window open after a batch file?

Edit your bat file by right clicking on it and select “Edit” from the list. Your file will open in notepad. Now add “PAUSE” word at the end of your bat file. This will keep the Command Prompt window open until you do not press any key.

How do I stop CMD from closing after batch file?

Add a pause statement to a batch file If you're creating a batch file and want the MS-DOS window to remain open, add PAUSE to the end of your batch file. This prompts the user to Press any key. Until the user presses any key, the window remains open instead of closing automatically.

How do I keep CMD open after execution?

Type the "cmd /k" parameter before every command to keep the window from closing.

How do I stop Command Prompt from closing after running?

If you want the command prompt cmd widnow to stay open after executing the last command in batch file –you should write cmd /k command at the end of your batch file. This command will prevent the command prompt window from closing and you'll get the prompt back for giving more commands in the cmd window.


1 Answers

Put pause at the end of your .BAT file.

like image 143
ElGavilan Avatar answered Sep 18 '22 17:09

ElGavilan