useful snippets
General Info
Useful Snippets

14.0.2 prevent a bat file from closing after the file is done running until you press a key

Description:

When a python file is run using a bat file, the cmd screen showing the output of the code will disapear quickly once the program is done running which makes it difficult to see what happened when you ran your python file.

If you don't want this screen to close once the program is done running, add the word 'pause' and then the screen won't close until you press a key to continue. Now the cmd screen will display this once the file is done running:

"Press any key to continue..."

don't forget to remove this after you're done checking things out if you plan to automate your code to run in the future

Example:

"C:\Program Files\Python38\python.exe"  "F:\the\location\of\your\python\file.py"
pause