When we run any batch file, the Command Prompt window will appear for shortly and it goes on the same time and you do not exactly get what commands run on CMD as the result of batch file.
Batch file contains commands to perform some actions related to System and these commands are executed one after another. So what if you want to watch your commands that you run through a batch file, and you want to prevent Command Prompt window from closing automatically.
Here are the 3 ways to prevent Command Prompt window from closing after running commands. Go for any solution you find easy and best for you.
Open the batch file in Notepad by right clicking on it and click on “Edit" from the list.
And paste the following command at the end of your batch file
Next, save the file by pressing “Ctrl+s" and close the notepad. Double click your .bat file. You will see that CMD will remain open as long as you want it to stay open.
This is the very easy and handy way to prevent the Command Prompt window from closing after running commands.
The second way I am going to show you is also a simple method.
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.
You can easily see each command which had run on the result of bat file in CMD as long as you do not press any key.
You can prevent Command Prompt window from closing after running commands through adding a Registry Key in the Windows Registry. For this, type the following code in your Notepad and save the file with the .reg extension.
After saving the file, double click on it. This registry will save to your Registry Editor of Windows. Now run any command, the Command Prompt window will stay open as long as you will keep it open.
These all are easy and quick ways to keep your window of the Command Prompt open so that you can easily configure and watch each command which you run through the batch file or Powershell Script. If you want to know anything else related to this, comment below. Thank you.