Reputation: 73
I have a little bat script that stops working every 20 minutes or so, so I want it to restart every 15 minutes or so. This is what I have so far:
@echo off
:A
start start.bat
timeout /t 1200 >null
taskkill /f /im cmd.exe >nul
pause
goto A
Obviously this doesnt work as it quits the script that is supposed to restart the script... Any tips for another way of doing this, or a fix for my restart script?
Upvotes: 0
Views: 3080
Reputation: 433
@echo off
:A
start "title" start.bat
timeout /t 1200 >nul
taskkill /F /FI "WindowTitle eq title - start.bat" /T
goto A
This should work. It sets a title of "title" to start.bat and then uses a filter to find that window and close it. The /T is just for closing the child processes too.
Upvotes: 1
Reputation: 43268
Scheduled tasks; run this job every fifteen minutes (yes it's a lot of start at entries) and [X] stop this job if it runs longer than 15 minutes.
Upvotes: 2