Page 1 of 1

Run command in specified time period

Posted: 02 Jul 2011 23:38
by mohdfraz
Hi K,

I want this command " copy *.log d:\log " to run in batch file from 10:00am to 1:00pm and from monday to friday. Once this time is over the batch file keep monitoring time to re-start this copy command when it comes in the specified time period.

Thanks in advance

Re: Run command in specified time period

Posted: 03 Jul 2011 00:20
by Ed Dyreen

You can use the sheduler to do this:

Code: Select all

schtasks /?
or

Code: Select all

at /?
Beware though, both methods have their advantages and disadvantages :!:

Code: Select all

   set "FullPath.SOURCE=!FullPath.PRGM3TH!\SYS\CFG\SchTasks"

   set "?=1sthMonth.CMD"    &set /p "?=  :/ !?!    "<nul
   ::(
      at 00:00 /interactive /every:1 "!FullPath.SOURCE!\!?!"
   ::)

   set "?=Saturday.CMD"    &set /p "?=  :/ !?!    "<nul
   ::(
      at 00:00 /interactive /every:za "!FullPath.SOURCE!\!?!"
   ::)
If you are writing a 'smart' batch, these system variables could be helpfull:

Code: Select all

echo.%DATE%
echo.%TIME%

Re: Run command in specified time period

Posted: 03 Jul 2011 01:34
by mohdfraz
Actually windows or dos Scheduler task running is not good for my situation. I want to check Time and run command or else. check this below example batch file code the end IF line i need to work out in dos language.

Example;
======================================================================
:RunMycommands
copy *.log d:\
ren *.log a.txt
etc....

:Loop
If time greater than 8:00 and less than 16:00 then Goto RunMyCommands Else Goto Loop
======================================================================

the commands i want to run continuously once after they finish and during all day in the specified time.