Take the 2-minute tour ×

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

share|improve this question
add comment

6 Answers

For the timer part of your script i highly reccomend using:

echo Waiting For One Hour... 
echo (Put some Other Processes Here)
pause >nul

This script waits for 1 hour (3600 seconds) and then continues on with the script and the user cannot press any buttons to bypass the timer (besides CTRL+C).

You can use

Timeout /t 3600 /nobreak >nul

If you don't want to see a countdown on the screen.

share|improve this answer
Nice. I just found this searching for a simple batch file timer solution - works great, thanks! EDIT: I am using this together with a goto-"loop" to create a simple script which periodically updates my SVN working copy. –  alexander.biskop Feb 27 '12 at 15:51
add comment

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

Control Panel -> Scheduled tasks

share|improve this answer
schtasks can be used from the command line to manipulate "Scheduled Tasks" –  Ken Gentle Nov 18 '08 at 17:29
The at command also does this. –  Blorgbeard Jan 29 '09 at 20:10
add comment

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.

share|improve this answer
add comment

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 Waiting for 1 minute...
  PING -n 60>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.

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

share|improve this answer
add comment

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.)

share|improve this answer
why is a graphics context needed to launch from the scheduler? I don't understand why that makes any difference. –  Tim May 8 '09 at 17:49
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 May 8 '09 at 20:48
add comment

You could also do this>

@echo off
set a=60
set /a a-1
if a GTR 1 (
echo %a% minutes remaining...
timeout /t 60 /nobreak >nul
goto a
) else if a LSS 1 goto finished

Or something like that.

share|improve this answer
add comment

Your Answer

