Link to home
Start Free TrialLog in
Avatar of smmsmm57
smmsmm57

asked on

Want to create .cmd or .bat file to spawn a subprocess, wait 10 minutes, kill it and restart it

I am hoping to create a .cmd file that has the ability to spawn a subprocess and then continue executing itself such that it has the ability to wait 10 minutes, kill the exe it started and then restart it......

Thanks....
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And a goto start at the end with a label at the start, i.e.


:start

REM start program in background
start myprog.exe

REM wait 10 mins
ping -n 1 -w 600000 AnIpAddressthatWillAlwaystimeout

REM Find process ID (resource kit command)
for /F "tokens=1,2 delims= " %a in ('pulist ^| find "myprog.exe"') DO echo KILL %b

goto start
What's with the b grade?  Did it work for you?