I am trying to start a .exe from a Python program, let it run for a couple of seconds and then kill it. I'm using the subprocess
library. Here's what I did (in short):
import subprocess
p = subprocess.Popen('start /b .\ssf.exe', shell=True)
time.sleep(5)
p.terminate()
I also tried p.kill()
, but without any luck.
Also, when I print(p.pid)
, it's a different PID than the one I find in the processes list... Can someone tell me why this is not working?