Subj : XBOOT3.BTM To : Jasen Betts From : Gerald Miller Date : Thu Oct 31 2002 09:01 am Hello Jasen, I /*think*/ I have a "stable" version for you to test out for me.... I still haven't figured out how to handle the four echo commands in the manner that you desire.... I am working on a method to change to date formatting within the data file, but in the meantime, you'll have to manually change the dates... === Cut Begin: XBOOT3.BTM === :: XBOOT3.BTM VERSION 1.3 Oct-19-2002 :: 01:30:00 :: (Once a day program upon boot execution) :: :: by Gerald Miller :: Fidonet 1:342/512 :: :: based on the original XBOOTEX.BTM by Klaus Meinhard :: Brahmsstr. 12 :: G 26842 Ostrhauderfehn :: Germany :: Compuserve 100115,2025 :: :: For those of you who have more extensive needs than can be filled :: by XDAILY.BTM, here is a utility that allows you a very versatile :: handling of programs you want to run only once a day at first boot :: time. :: :: XBOOT3 allows you to specify as many programs as you wish in the :: data file XBOOT3.DAT, with an interval in days for running each :: program and the possibility to ask if the program should be run :: (nice if you do not have the time for it just then). You will be :: asked again the next day if you skip. :: :: If you want to run another batch file, enter `CALL c:\path\mybatch` :: in XBOOT3.DAT to insure the return to XBOOT3.BTM after execution. :: :: So maybe you want to run STACKER's CHECK every day, but a virus :: scanner only once a week, and defrag once a month? No problem, :: just fill in those programs in XBOOT3.DAT with the appropriate :: parameters. Just be careful not to change the formatting of that :: file, because XBOOT3.BTM depends on it. :: :: There is an example data file (XBOOT3.DAT) which shows the working of :: all this and makes calls to eight BTM files to show you how XBOOT3 :: works. :: :: Some of the NEXT RUN date field and DAYS LEFT field within the :: XBOOT3.DAT file are "zeroed" out on the theory that the first time you :: execute the XBOOT3.BTM, all the fields should contain the "correct" :: data upon completion. :: :: The eight "simple" BTM files all echo their name to the screen and :: "touch themselves" when called upon based on the information contained :: in the data file. (The date and time stamp of the eight BTM files will :: change based on execution.) :: :: Call XBOOT3.BTM from your autoexec.bat. XBOOT3.DAT _must_ be in :: your path or the root dir of your boot drive! :: :: ** Features fixed / added / pending: :: :: - Removed all "_" characters from non-4DOS variable names to avoid :: possible conflict of future 4DOS variable names. (Thanks Jasen :: Betts @Fidonet 3:640/531.42) :: - Calculate the date of a program's next call. :: - Calculate the number of days remaining until the next call. :: :: I recommend that all the CALLed batch files end with: :: :: touch /q %_batchname :: :: to serve as an indicator of when that batch file was last run. I :: ****DO NOT**** recommend that you use the touch command on :: ****ANY**** executable (i.e.: *.EXE, *.CMD, etc.) file!!! :: :: Further suggestions welcome :: :START *setlocal *unalias * :: The following section will change the date and time stamp of XBOOT3.BTM :: I use the data to maintain the XBOOT3.BTM version number sequence. :: PLEASE LET ME KNOW IF THE TOUCH SEQUENCE SHOULD GIVE YOU ANY PROBLEMS. iff %@fileage[%_batchname] ne %@makeage[10-19-02,01:30:00] then touch /d10-19-02 /t01:30:00 %_batchname endiff :: ###WARNING### :: You ARE required to change "q3" (in the next line) to the path\name :: of your text editor!!! :: DO IT NOW BEFORE YOU GET AN ERROR MESSAGE IF THERE IS AN ERROR!!! :: "Q3" is my version of the Semware Editor. on error (q3 /n%_batchline %@search[%0] %+ quit) on break goto END if "%temp" eq "" set temp=C:\ :: Next command establishes the location of the variable "BOOTFILE" :: (XBOOT3.DAT) [should probably be in the same directory as this BTM :: file...] set bootfile=%@path[%@search[%0]]%@name[%0].DAT :: Next command establishes the location and name of the variable "TEMP" :: that holds the temporary information while the action is performed. set temp=%temp\%@name[%0].TMP :: User input if [%1]==[-?] .or. [%1]==[/?] .or. [%1]==[?] goto USAGE :: Is the file XBOOT3.DAT there? Where? iff not exist %bootfile then echo. color bri red on whi echo ERROR: %@path[%@search[%0]]%@name[%0].DAT not found! color bri cya on bla echo. delay 5 goto END endiff :: Set variables. If XBOOT3 did it's job today already or it's before :: 00:01 am, do nothing. In this case, the "start" time is 00:01 am.... set lastdate=%@date[%@filedate[%bootfile]] set today=%@date[%_date] set dotime=00:01 if %@eval[%lastdate - %today] eq 0 .or. %@eval[%@time[%_time] - %= %@time[%dotime]] le 0 goto END :: Read XBOOT3.DAT, look at which progs to run today, copy info to :: XBOOT3.TMP and update XBOOT3.DAT set i=0 echo. echo %@line[%bootfile,0]>%temp echo %@line[%bootfile,1]>>%temp echo %@line[%bootfile,2]>>%temp do n=3 to %@lines[%bootfile] set prog=%@instr[0,41,%@line[%bootfile,%n]] set when=%@instr[42,5,%@line[%bootfile,%n]] set last=%@instr[48,8,%@line[%bootfile,%n]] set next=%@instr[57,8,%@line[%bootfile,%n]] set left=%@instr[66,5,%@line[%bootfile,%n]] set ask=%@instr[72,1,%@line[%bootfile,%n]] iff %@eval[%today-%@date[%last]] ge %when .and. "%prog" ne "" then iff "%ask" eq "Y" then beep 294 2 330 2 277 2 294 2 330 2 277 2 294 2 330 2 277 2 294 2 %= 330 2 0 2 139 2 165 2 196 2 233 2 277 2 466 2 554 2 659 2 784 2 932 2 scrput %_row %@eval[17+%@len[%prog]] bri yel on bla `Y` inkey /c/K"YN[esc][enter]" `Execute `%@upper[%prog]` [Y/N] ?` %%ink echo. iff "%ink" eq "Y" .or. "%ink" eq "@28" then set i=%@inc[%i] set run%i=%prog set nextdate=%@date[%@eval[%@date[%today] + %when]] set daysleft=%@date[%@eval[%@date[%nextdate] - %today]] echo %@format[-41.41,%prog]³%@format[-5.5,%when]³%= %@makedate[%today]³%@makedate[%nextdate]³%@format[-5.5,%daysleft]³%ask>>%temp else set nextrun=%@date[%@eval[%@date[%last] + %when]] set daysleft=%@date[%@eval[%@date[%nextrun] - %today]] echo %@format[-41.41,%prog]³%@format[-5.5,%when]³%= %@format[-8.8,%last]³%@makedate[%nextrun]³%@format[-5.5,%daysleft]³%ask>>%temp endiff endiff iff "%ask" eq "N" .or. "%ask" eq "" then set i=%@inc[%i] set run%i=%prog set nextdate=%@date[%@eval[%@date[%today] + %when]] set daysleft=%@date[%@eval[%@date[%nextdate] - %today]] echo %@format[-41.41,%prog]³%@format[-5.5,%when]³%= %@makedate[%today]³%@makedate[%nextdate]³%@format[-5.5,%daysleft]³%ask>>%temp endiff elseiff "%prog" ne "" then set nextrun=%@date[%@eval[%@date[%last] + %when]] set daysleft=%@date[%@eval[%@date[%nextrun] - %today]] echo %@format[-41.41,%prog]³%@format[-5.5,%when]³%= %@format[-8.8,%last]³%@makedate[%nextrun]³%@format[-5.5,%daysleft]³%ask>>%temp endiff unset /q prog nextdate daysleft nextrun enddo move /q/u %temp %bootfile >& nul iff "%i" ne "0" then do m=1 to %i echo. %+ echo. color bri whi on whi echos XBOOT3 Program Execution: color bri cya on bla echo %@upper[%[run%m]] echo. %[run%m] @echo off enddo endiff echo. color bri red on whi echos XBOOT3 END color bri cya on bla echo. :END color bri cya on bla if exist %temp del /q %temp > nul endlocal color bri cya on bla quit :USAGE color bri cya on bla text ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ XBOOT3 ÄÄÄÄÄÄÄ Once a day program execution with many options ³ ³ (selectable intervals, ask before execution). ³ ³ For more info see the header of this file. ³ ³ ³ ³ XBOOT3.DAT is the data file XBOOT3.BTM, where ³ ³ you can enter your progs and parameters. It ³ ³ _must_ be in your path or the root dir of your ³ ³ boot drive. ³ ³ ³ ³ XBOOT3 should be _called_ from autoexec.bat ³ ³ ³ ³ Syntax: XBOOT3 /? -? Syntax (this screen) ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ endtext delay 5 goto END === Cut End: XBOOT3.BTM === For my sample data file.... === Cut Begin: XBOOT3.DAT === PATH\PROGRAM TO RUN ³AFTER³ ³ ³DAYS ³ ³ DAYS³LAST RUN³NEXT RUN³ LEFT³ASK ÄÄÄÄ 001 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÅMM-DD-YYÅMM-DD-YYÅÄÄÄÄÄÅÄÄÄ call STEP_0.BTM ³1 ³10-31-02³00-00-00³0 ³N call STEP_1.BTM ³1 ³10-31-02³00-00-00³0 ³N call STEP_2.BTM ³14 ³10-19-02³00-00-00³0 ³N call STEP_3.BTM ³28 ³10-26-02³00-00-00³0 ³N call STEP_4.BTM ³7 ³10-26-02³00-00-00³0 ³N call STEP_5.BTM ³2 ³10-30-02³00-00-00³0 ³N call STEP_6.BTM ³3 ³10-30-02³00-00-00³0 ³N call STEP_7.BTM ³4 ³10-30-02³00-00-00³0 ³N === Cut End: XBOOT3.DAT === I haven't bothered to convert all the high ASCII characters.... I'll include a sample TEST batch file (STEP_0.BTM) and you can copy it to the other seven test files... === Cut Begin: STEP_0.BTM === echo. %+ echo This is %@upper[%@name[%_batchname]]. %+ echo. touch /q %_batchname === Cut End: STEP_0.BTM === As usual, I'm not responsible for any damages.... :-) Cheers ... Gerald --- GoldED+/386 v1.1.5-21026 * Origin: An Oiler fan since the days they played outdoors. (1:342/512) .