I have a batch file which is deployed to machines as soon as they're able to receive the file (which is a variable - as some may be offline, busy, or delayed), but it should only run it the current local time is inside a specified window.
Eg, only between 12am & 2am.
I do have the following working with PM times- But apparently it will not execute if I specify any single (or double) digit AM hours here (such as 1am through to 9am).
@echo off
SET hour=%time:~0,2%
SET shouldrun=True
IF %hour% leq 23 SET shouldrun=False
IF %hour% geq 02 SET shouldrun=False
IF "%shouldrun%"=="False" (
echo Outside Update Schedule
EXIT /B 1
)
IF "%shouldrun%"=="True" (
@TASKKILL /f /im some.exe > nul 2>&1
@timeout /t 4 > nul
- do things here -
@timeout /t 2 > nul
shutdown -r -f -y -t 2
EXIT /B 0
)