Skip navigation

JSI Tip 1364. Prevent scheduled jobs from running on a holiday.

If you wish to prevent scheduled jobs from running on a holiday, add:

call holiday
if "%holiday%"

"Y" exit


call holiday
if "%holiday%""Y" go to endlabel

to the beginning of your batch jobs.

Place holiday.dat, containing the holiday dates, in the folder that your scheduled jobs start in. To determine the starting folder:

AT HH:MM /interactive cmd /k

where HH:MM is two minutes from now. When the command prompt opens, you will see the folder. You can also change holiday.dat in holiday.bat to <Drive:>\Folder\holiday.dat.

To determine the format of the date in holiday.dat, type:

date /t

On JSI's computers, it returns:


Add as many dates (MM/DD/YYYY) to holiday.dat as you wish. Don't forget to remove old dates and add new ones each year.

Set permissions on holiday.dat so that you have Full Control and the Schedule service account has Read.

Place holiday.bat in the %PATH%. Holiday.bat contains:

@echo off
for /f "tokens=1* delims=/ " %%i in ('date /t') do set today="%%j"
set today=%today: =%
set holiday=N
for /f "Tokens=*" %%i in (holiday.dat) do call :test "%%i"
endlocal&set holiday=%holiday%
goto end
set fdate=%1
set fdate=%fdate: =%
if %fdate% EQU %today% set holiday=Y

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.