I am creating a batch file to run a program on my desktop xyz.exe
for 4 hours, then close it for 1 hour and repeat the process. Here is my script.
:a
START C:\Users\Mukul\Desktop\xyz.exe
SLEEP 14400
taskkill /F /IM xyz.exe
SLEEP 3600
goto :a
According to here, the script should wait. It also says:
SLEEP 10
will delay execution of the next command by 10 seconds. so SLEEP 14400
should delay the execution by 4 hours.
Current results: Next command gets executed as soon as the first command completed.
Desired results: Next command should wait for 4 hours before executing the last command.
You can use batch's timeout
command.
For example:
@echo off
echo Hi
timeout /t 1 /nobreak > nul
/t
is not mandatory
1 is the amount of second(s) to wait
/nobreak
ensures the user can't skip the wait
> nul
redirects output to nothing, so you don't see anything