Someone asked to see my buMAIL.bat when I completed it, so here it is (I
even documented it a bit!).  It requires calling more external bits of
code than I like, but it works on my Win2k ThinkPad.

If anyone has any suggestions on easier/better (I know, that is
subjective) ways to do parts of it I would be interested in hearing
about it.

,----- [  ]
| @echo off
| :: Back up my The Bat! Registry key & MAIL directory
| :: By Tim Musson, March 2003.
| :: I use the for/do and if/else commands with Win2k syntax, 
| ::    so it may not work on other MS OS's, I don't know...
| :: Requires
| ::    PsList from sysinternals.com
| ::    sleep.exe from MS Resource kit.
| ::    regedit switch docs at 
| ::    RAR from www.rarlab.com
| 
| ::Ok, lets shut TB down!
| "C:\Program Files\The Bat!\thebat.exe" /EXIT
| 
| ::We should wait for TB to exit...
| :: possibly find a better programmatic way to check?
| :Check
| :: so, we use the for/do command to pull apart the output of the
| :: PsList.exe command, setting the Process Name to the TBup var
| for /f "tokens=1*" %%i in ('pslist thebat') do  set TBup=%%i
| :: Now we use the if/else command to check what is in the TBup var
| :: and sleep.exe for a second an check it again.
| IF %TBup%.==thebat. (
|       echo %TBup% running, check again... & sleep 1
| ) ELSE (
|       echo %TBup% down, Back It Up! & goto :BackItUp
| )
| goto :Check
| 
| :BackItUp
| ::Now we dump the reg key for TB (keeping a backup if it exists)
| set BUfilename="\MAIL\TheBatRegBU.reg"
| copy %BUfilename% %BUfilename%.old /y
| regedit /e %BUfilename% HKEY_CURRENT_USER\software\rit
| 
| ::Build a DTS variable
| :: Using for/do, pull apart the output of date/t
| set parsearg="eol=; tokens=1,2,3,4* delims=/, "
| for /F %parsearg% %%i in ('date/t') do set ds=%%l.%%j.%%k
| 
| :: Use the output of the above for/do in the next for/do
| :: Using for/do, pull apart the output of time/t
| set parsearg="eol=; tokens=1,2* delims=:, "
| for /F %parsearg% %%i in ('time/t') do set dts=%ds%-%%i.%%j
| 
| ::Here is where we make a backup of the MAIL directory
| :: Now, I just need to put in a DateStamp as part of the FileName.rar
| :: Will use another for/do command to build it when I have the time.
| "C:\Program Files\WinRAR\RAR.exe" a E:\MAILbu%dts%.rar E:\MAIL
| 
| start "starting TB" "C:\Program Files\The Bat!\thebat.exe" /MINIMIZE
`-----

-- 
Tim Musson
Flying with The Bat! eMail v1.62 Christmas Edition
Windows 2000 5.0.2195 (Service Pack 2)
Keyboard not available - Press F1; to continue.


________________________________________________________
 Current version is 1.61 | "Using TBTECH" information:
http://www.silverstones.com/thebat/TBUDLInfo.html

Reply via email to