Executing a program from python so that it opens in separate cmd.exe window

cmd, python, subprocess

Solution

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)

Problem

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.

Original source

Related problems