Stop Command Prompt Window from Closing

A simple method to prevent command prompt window from closing after execution of a batch file.

Batch files are a series of commands that are executed in a sequence. People generally write batches of DOS commands and shell commands. When you execute a DOS (Windows) batch file by double clicking the .bat file –the command prompt windows pops up, execute commands quickly and then disappears.

But if you want the command prompt to stay open after executing the last command in batch file –you should write cmd /k command in the end. This command will prevent the command prompt window from closing and you’ll get the prompt for giving more commands in the window.

A typical use case of this scenario is when you want a command prompt window ready after auto-executing of certain commands that you always give (For example, changing drive or directory).

Leave a Reply

Your email address will not be published. Required fields are marked *