Command prompt closes after I run my.exe from python script

Viewed 21
import sys
import subprocess
import os

os.chdir("C:\\code\\runcommand\\")
command = "my.exe"
subprocess.Popen(command)

with above code my.exe runs on command prompt and gets closed. How to prevent command prompt from closing.

1 Answers

If you simply want leave open the command prompt you can add input() as last line (read more...). Then cmd will be close after hitting any key.

Related