After start.exe
is executed by Python, the output of start.exe
is displayed in the python stdout. However 5 seconds later, we do not see Quitting
printed and the task is not killed.
Is there an easier way to terminate an exe that was originally started by Python? Like getting a handle for the exe executed and using that handle to kill the process.
import subprocess
import os
import time
subprocess.call(['.\\start.exe'])
time.sleep(5)
print("Quitting")
os.system("taskkill /im start.exe")