Reputation: 2940
How can I execute a program from within python program so that it opens in a separate cmd.exe window with the output of the executed program? I tried using subprocess.popen but it doesn't display the cmd.exe window while the program is running.
Upvotes: 2
Views: 8753
Reputation: 6797
In Windows, you need to declare optional variable shell=True and use start:
subprocess.Popen('start executable.exe', shell=True)
or if you want to kill the shell after running the executable:
subprocess.Popen('start cmd /C executable.exe', shell=True)
For example:
subprocess.Popen('start dir', shell=True)
subprocess.Popen('start cmd /C dir', shell=True)
Upvotes: 7