tags:

views:

7132

answers:

4

How do I create a batch file timer to execute / call another batch through out the day Maybe on given times to run but not to run on weekends ? Must run on system times can also be .cmd to run on xp server 2003

A: 

I did it by writing a little C# app that just wakes up to launch periodic tasks -- don't know if it is doable from a batch file without downloading extensions to support a sleep command. (For my purposes the Windows scheduler didn't work because the apps launched had no graphics context available.)

Jeff Kotula
why is a graphics context needed to launch from the scheduler? I don't understand why that makes any difference.
Tim
In my case I needed to launch an application to run automated tests which did lots of graphics (medical imaging). So they wouldn't run without a graphics context.
Jeff Kotula
+7  A: 

I would use the scheduler (control panel) rather than a cmd line or other application.

Control Panel -> Scheduled tasks

Tim
`schtasks` can be used from the command line to manipulate "Scheduled Tasks"
Ken Gentle
The `at` command also does this.
Blorgbeard
+2  A: 

The AT command would do that but that's what the Scheduled Tasks gui is for. Enter "help at" in a cmd window for details.

SumoRunner
+1  A: 

Below is a batch file that will wait for 1 minute, check the day, and then perform an action. It uses PING.EXE, but requires no files that aren't included with Windows.

@ECHO OFF

:LOOP
ECHO Waiting for 1 minute...
  PING -n 60 127.0.0.1>nul
  IF %DATE:~0,3%==Mon CALL SomeOtherFile.cmd
  IF %DATE:~0,3%==Tue CALL SomeOtherFile.cmd
  IF %DATE:~0,3%==Wed CALL SomeOtherFile.cmd
  IF %DATE:~0,3%==Thu CALL WootSomeOtherFile.cmd
  IF %DATE:~0,3%==Fri CALL SomeOtherFile.cmd
  IF %DATE:~0,3%==Sat ECHO Saturday...nothing to do.
  IF %DATE:~0,3%==Sun ECHO Sunday...nothing to do.
GOTO LOOP

It could be improved upon in many ways, but it might get you started.

aphoria