Reputation: 79
I'm looking for a script who can realize this sequence.
Can you help me manage this problem ? Thanks a lot !
Regards,
Upvotes: 3
Views: 16319
Reputation: 9806
There is a post here Batch file - restart program after every 20 minutes
@echo off
:loop
start yourtarget.exe ...
timeout /t 1200 >null
taskkill /f /im yourtarget.exe >nul
goto loop
Upvotes: 6
Reputation: 1177
@set /A _tic=%time:~0,2%*3600^
+%time:~3,1%*10*60^
+%time:~4,1%*60^
+%time:~6,1%*10^
+%time:~7,1% >nul
:: actual script
@set /A _toc=%time:~0,2%*3600^
+%time:~3,1%*10*60^
+%time:~4,1%*60^
+%time:~6,1%*10^
+%time:~7,1% >nul
: loop
@set /A _elapsed=%_toc%-%_tic
@echo %_elapsed% seconds.
:: check for elapsed time here
:: kill the app
taskkill /im <yourappname>
:: sleep for some time
timeout /T 10
:: start again
start <yourappname>
goto loop
Upvotes: 1
Reputation: 4847
Python is an option here:
import subprocess, time
while True:
proc=subprocess.Popen("something.exe")
time.sleep(3*60*60) # 3 hours
proc.kill()
time.sleep(30) # 30 seconds
Upvotes: 3