|
Answer» Hi! sorry for my english.
I have a need for a batch file that is EXECUTED by windows task manager, in it it will PING several machines every 60 seconds, but I need to make it do that for just 12 HOURS. I tried to search for a post here but I could not find it.
I'm using choice to give the PAUSE between pings, but I don't know how to make it play for 12 hours.
Hope you can help me.
I use windows vista.you could try having a statement something like: 'set startTime=%time%' and then find the differance in the current time and %startTime%, 'if %diffrence% LSS 12 goto :loop'. (It might take a few trials to get it working correctly.) Hope this helps!Which 12 hours? AM? PM? Some other mixture?It will start aprox 4 am and finish 12 hours laterCall this batch file gethour.bat and add a line in yours that looks like this, to quit once it reaches 4pm.
:: add to your batch file Code: [Select]call gethour.bat if %hour% GTR 15 goto :EOF
:: gethour.bat Code: [Select]@echo off setlocal EnableExtensions :: DATE and time routines by Ritchie Lawrence :: Windows NT4 and above :begin (set today=%date%) set t=2&if "%date%z" LSS "A" set t=1 for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo/^|date') do ( for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do ( set %%a=%%d&set %%b=%%e&set %%c=%%f)) (set yy=%yy%&set mm=%mm%&set dd=%dd%) for /f "tokens=5-8 delims=:. " %%a in ('echo/^|time') do ( set hh=%%a&set nn=%%b&set ss=%%c&set cs=%%d) if 1%hh% LSS 20 set hh=0%hh% (set hh=%hh%&set nn=%nn%&set ss=%ss%&set tt=%cs%) if not "%date%"=="%today%" goto :begin
:: The following lines set and echo the timestamp variable set timestamp=%yy%-%mm%-%dd%_%hh%.%nn%.%ss% set hour=%hh%
|