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....
smmsmm57Asked:
Who is Participating?
 
Steve KnightIT ConsultancyCommented:
something along these lines perhaps:

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

Remove the echo before the KILL to kill the process.

0
 
Steve KnightIT ConsultancyCommented:
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
0
 
Steve KnightIT ConsultancyCommented:
What's with the b grade?  Did it work for you?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.