sleep function in a batch script
You can also use timeout
.
Here is an example:
@echo off
echo Hi
timeout /t 1 /nobreak > nul
/t
is not mandatory1 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
SLEEP command may not be supported by your Windows version. Try this:
:a
START C:\Users\Mukul\Desktop\xyz.exe
TIMEOUT 14400
taskkill /F /IM xyz.exe
TIMEOUT 3600
goto :a
First off: Bash and Batch are very different languages.
Now, the answer.
I prefer the ping
command over the sleep
command, for it's easy switching between seconds and milliseconds:
ping -n 11 127.0.0.1>nul
That command pauses for 10 seconds then resumes.
Or:
ping 1.1.1.1 -n 1 -w 10001 >nul
Which also pauses for 10 seconds, but in milliseconds.
Either can be adapted into:
:a
start C:\Users\Mukul\Desktop\xyz.exe
ping -n 14401 127.0.0.1>nul
taskkill /F /IM xyz.exe
ping -n 3601 127.0.0.1>nul
goto a
DISCLAIMER: I have NOT tried the final piece of code (because I don't have 4 extra hours to do something).