pythonbatch-filecmdoperating-systemos.system

Run CMD command in python script in ANOTHER Shell


I am running a pogram "xxx" in the windows cmd shell. With a python script I want to check whether this specific process "xxx" is frozen or not. If so, it should reopen the process with

os.system(r'xxx.bat')

but then the python script does no check anymore because its running the process...

How can I open another, standalone CMD Terminal so that the python script starts checking again immediately after opening the shell?


Solution

  • For a non-blocking solution, you should try: os.startfile(xxx.bat)

    However, note that os.startfile() will run the file with the application associated to the extension of said file.