views:

42

answers:

1

I'd like to create a small script to that basically does this: run program1.exe --> kill program1.exe after n seconds --> run program1.exe again. I know some basic Python and would read up on this, but I'm in a bit of a hurry and just need this to get done asap.

If someone has a script/idea or could help my out with just the syntax I need to open and kill the .exe file, please... I don't mind solutions in other languages either. I'm sorry if this is a bit "please write my code"-ish, that's not something I typically do.

+3  A: 

Read up on the subprocess module.

import subprocess, time
p = subprocess.Popen(['program1.exe'])
time.sleep(1) # Parameter is in seconds
p.terminate()
p.wait()
Magnus Hoff
Thanks, I think that was just what I needed! :)
Fredrich