2
votes

I have batch file that runs python script. But, once python script finishes, cmd stays open.. How can I close it?

Thank you!

Edit: .bat script looks something like this:

C:\Users\USER\AppData\Local\Programs\Python\Python36\python.exe C:\Users\USER\Documents\Code\python\some-dir\script.py %1 %2

And then python script runs, and once it ends, cmd window from batch file remains open.. Can I close it somehow from python script itself or something?

Edit2: Nevermind, figured it out. You can just add exit at end of the batch file, and it will run once the python script ends

1
Can you provide a minimal reproducible example of the behavior? Both batch file and python? - Jeff Zeitlin
Added an example of batch script I use, it just runs a python file and passes it two variables - bawsi

1 Answers

2
votes

Just create a line with the exit command at the end of the batch file. That will close the cmd window when it reaches the end.