echo off
echo.
echo ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
echo ³ Run a program only once a day at boot time        ³
echo ³ By Prof. Timo Salmi, ts@uwasa.fi, Wed 16-Sep-1992 ³
echo ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

if "%1"=="" goto _help

rem What date was this bacth last run
if exist date1$$$ goto _date_now
echo Not yet run today > date1$$$

:_date_now
rem What is the current date
echo.|date > date2$$$

rem Compare the last and the current date
fc date2$$$ date1$$$ > tmp$$$
type tmp$$$ | find "no differences encountered" > same$$$
del tmp$$$
if exist doit$$$ del doit$$$
copy same$$$ dont$$$ > nul
del same$$$

rem Move the current date information to the last run date variable
copy date2$$$ date1$$$ > nul
del date2$$$

rem Don't run if the dates match
if exist dont$$$ goto _done

rem Make the call
call %1 %2 %3 %4 %5 %6 %7 %8 %9
goto _out

:_help
echo.
echo If you want to run a program only once a day when you reboot
echo your computer, put
echo.
echo   CALL DAILY YourApplicationName [Param1] [Param2] [...]
echo.
echo in your autoexec.bat file.
echo.
goto _out

:_done
del dont$$$
echo %0 has already been run today

:_out
