Run a specified program only on certain days at boot time.
This demo makes use of two tricks: It reads a custom INI file, and it puts the current day into the environment.
@echo off
:: This batch file allows you to run programs on certain days.
:: Have this TODAY.BAT program CALLed from your AUTOEXEC.BAT.
:: TODAY.BAT will read entries in a TODAY.INI file you must make.
:: The entries in the TODAY.INI should look like this:
:: 10-12-1999=DeleteOldDocs.bat
:: 10-13-1999=Scandisk.bat
:: 10-14-1999=PrintReports.bat
:: Put the date into the DATE environment variable
:: Response to DATE command should be like
:: Current date is Sun 10-12-1997
:: Enter new date (mm-dd-yy):
@echo.|date|find /i “current”>#urrent.bat
@echo set date=%%4>current.bat
call #urrent.bat
del ?urrent.bat
:: Put the command for today into TODAYSCOMMAND variable
:: Assumes existence of TODAY.INI in current directory
find “%date%=” today.ini | sort /r | date | find “=” > en#er.bat
@echo set todayscommand=%%5> enter.bat
call en#er.bat
del en?er.bat > nul
:: Cleanup - delete DATE variable and INI entry (so it only runs once)
type today.ini|find /v “%date%”>today.ini
set date=
:: Run today’s command
call %todayscommand%
set todayscommand=
:: _____________________________________________________
:: If the command for the day requires user input, for
:: example, you have to hit enter or answer yes or no,
:: you should run a separate batch file instead of
:: running the command directly. Assume you want to run
:: CHKDSK with the /F option to fix errors. If it finds
:: errors, it will ask you to type “y” or “n”. You can
:: create a batch file which will do this for you:
:: ECHO Y|CHKDSK /F
:: If all you need is to press “Enter”, you can do this:
:: ECHO.|CHKDSK /F
:: If you need to press “y”, AND THEN HIT “Enter”, it
:: gets more complicated. You have to create what is
:: generally called a “script” containing the exact
:: keystrokes you need to press. You can create it
:: ahead of time, or as needed like this:
:: ECHO Y>SCRIPT.TXT
:: ECHO.>>SCRIPT.TXT
:: TYPE SCRIPT.TXT|CHKDSK /F
:: Notice the first line had only one “>”, but the
:: second line had two “>>”. Just one will cause
:: the SCRIPT.TXT to be created new (if it already
:: exists, it will be erased to start over fresh).
:: The two >> will cause things to be appended to
:: the existing SCRIPT.TXT
Have your batch file send the desired answer..
