set /a %v%= %time% + 5 minutes

May 24, 2011 at 17:33:01
Specs: Windows XP
I have a bat file that runs a command every 5 minutes. I have tried alot of stuff but none works.
here is what i got so far
set t=%time%
set m=!t:~3,2!
set h=!t:~0,2!
set /a m1= m + 5
:l
cls
echo %H%:%m1%
if %time%==%m1% echo hi && pause
goto L

Now of course i changed the output though echo hi is not the real command ;)


See More: set /a %v%= %time% + 5 minutes

Report •


#1
May 25, 2011 at 01:28:41
Time math is just about hopeless. Use PING to give you a delay.


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
May 26, 2011 at 00:04:14
It can be done but probably shouldn't be...

I was bored..

@echo off

rem seconds to wait
rem sec_elp must be less than 86400 (23:59:59 max)
set sec_elp=300

:restart
set t=%time: =0%
set /a stop=((1%t:~0,2% %% 100) * 3600) + ((1%t:~3,2% %% 100) * 60)+ (1%t:~6,2% %% 100)
set /a stop= stop + sec_elp

:l
rem cls

set t=%time: =0%
set /a check=((1%t:~0,2% %% 100) * 3600) + ((1%t:~3,2% %% 100) * 60) + (1%t:~6,2% %% 100)

if %stop% gtr 86400 if %check% lss 3600 set /a stop=stop %% 86400


if %check% geq %stop% echo hi & title now & pause & goto restart

rem **** Start display ****
set /a disp=stop - check
set /a hh=disp / 3600
set /a mm=(disp - (hh * 3600)) / 60
set /a ss=disp - ((hh * 3600) + (mm * 60))
if "%hh:~1%"=="" set hh=0%hh%
if "%mm:~1%"=="" set mm=0%mm%
if "%ss:~1%"=="" set ss=0%ss%
title Time to elapse: %hh%:%mm%:%ss%
rem **** end display ****
goto L


Report •

Related Solutions


Ask Question