@echo off
:: GET CURRENT ABSOLUTE MINUTE AND PUT IN ENVIRONMENT VARIABLE RUNTIME
FDATE /Ff /At /Ominute# /vRUNTIME
:: ADD 120 MINUTES (2 HOURS) TO ENVIRONMENT VARIABLE RUNTIME
FDATE /F#add /A%RunTime% /B120 /vRUNTIME
:: LOOP UNTIL NOWTIME HAS REACHED RUNTIME
:LoopTop
FDATE /Ff /At /Ominute# /vNOWTIME
Fdate /Ff /Osecond#
FDATE /F#comp /A%NowTime% /B%RunTime% /vTIMECOMP
if (%TimeComp%)==(LT) goto LoopTop
:LoopEnd
echo STARTING EXECUTION OF APPLICATION: [program name]
.DISCUSSION..:
If you are running on a system that doesn't support the /V parm, you can
use the following code.
The problem with this technique is that it is constantly writing a new
copy of TEMP.BAT to your hard disk. A lot of wear and tear on your hard
disk. Back in the days when DOSausaurs ruled the earth, and people
routinely used virtual disks, that wasn't a problem. But nowadays
(September, 2001) I wouldn't use it except as a last resort.
.CODE........: @echo off
:: GET CURRENT ABSOLUTE MINUTE AND PUT IN ENVIRONMENT VARIABLE RUNTIME
FDATE /Ff /At /Ominute# /p"set RUNTIME=" > temp.bat
call temp.bat
:: ADD 120 MINUTES (2 HOURS) TO ENVIRONMENT VARIABLE RUNTIME
FDATE /F#add /A%RunTime% /B120 /p"set RUNTIME=" > temp.bat
call temp.bat
:: LOOP UNTIL NOWTIME HAS REACHED RUNTIME
:LoopTop
FDATE /Ff /At /Ominute# /p"set NOWTIME=" > temp.bat
call temp.bat
FDATE /F#comp /A%NowTime% /B%RunTime% /p"set TIMECOMP=" > temp.bat
call temp.bat
if (%TimeComp%)==(LT) goto LoopTop
:LoopEnd
:: cleanup
del temp.bat
echo STARTING EXECUTION OF APPLICATION: [program name]