What command can I put at the end of a batch file to prevent auto-closing of the console after the execution of the 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.
If the system file is damaged, it may also cause the problem that CMD opens and closes immediately in Windows 10. For this, you can try to fix this problem by running the Windows 10 System File Checker (SFC).
In Windows/DOS batch files:
pause
This prints a nice "Press any key to continue . . . "
message
Or, if you don't want the "Press any key to continue . . ."
message, do this instead:
pause >nul
Depends on the exact question!
Normally pause
does the job within a .bat file.
If you want cmd.exe not to close to be able to remain typing, use cmd /k
command at the end of the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With