@echo off rem --Description: rem -- rem -- This script attempts to solve some of the problems which Hamish's and his rem -- workmates have been having with their access database. At the moment, all that rem -- the script does is copy the database to a backup folder at regular intervals. rem -- rem -- The script should also rename the file using the date and time. I think that rem -- NT command substitution supports this. rem -- rem -- The script could also do things like use 'blat' to email a notification rem -- message to Hamish if the database becomes corrupt. rem -- rem --Notes: rem -- rem -- It is possible that repairing should be done through rem -- control panel -> administrative tools -> odbc sources rem -- according to one internet source this is more reliable for access 97 than rem -- command line switches or using the Access GUI itself rem -- rem --Author: rem -- matthew bishop rem -- matth3wbishop@yahoo.com rem -- http://www.geocities.com/matth3wbishop rem -- The variables below should be appropriate for using in the CSU environment rem ? set ACCESSEXE="c:\Program Files\Microsoft Office\Office10\msaccess.exe" rem set BACKUPFOLDER=s:\centres\enterprises\eal\labtrack rem set DATAFOLDER=d:\data\labtrack_db rem set DATABASENAME=eal61.mdb rem -- The variables below are suitable for testing in the library rem -- @echo on set ACCESSEXE="c:\Program Files\Microsoft Office\Office10\msaccess.exe" set BACKUPFOLDER=c:\corrupt61\bak set DATAFOLDER=c:\corrupt61 set DATABASENAME=eal61.mdb copy /Y %DATAFOLDER%\%DATABASENAME% %DATAFOLDER%\temp-a.mdb copy /Y %DATAFOLDER%\%DATABASENAME% %DATAFOLDER%\temp-b.mdb %ACCESSEXE% %DATAFOLDER%\temp-a.mdb /compact @echo off call :GetDate year month day call :GetTime hours mins secs hsecs call :MonthName %month% monthname copy /Y %DATAFOLDER%\%DATABASENAME% %BACKUPFOLDER%\eal61-%year%-%month%-%day%-%hours%-%mins%.mdb goto :EOF @echo off call :GetDate year month day echo/Today is: %year%-%month%-%day% goto :EOF ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :GetDate yy mm dd :: :: By: Ritchie Lawrence, 2002-06-15. Version 1.0 :: :: Func: Loads local system date components into args 1 to 3. For NT4/2K/XP :: :: Args: %1 var to receive year, 4 digits (by ref) :: %2 var to receive month, 2 digits, 01 to 12 (by ref) :: %3 Var to receive day of month, 2 digits, 01 to 31 (by ref) ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: setlocal ENABLEEXTENSIONS set t=2&if "%date%z" LSS "A" set t=1 for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo/^|date') do ( for /f "tokens=%t%-4 delims=.-/ " %%d in ('date/t') do ( set %%a=%%d&set %%b=%%e&set %%c=%%f)) endlocal&set %1=%yy%&set %2=%mm%&set %3=%dd%&goto :EOF ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: echo off call :GetTime hours mins secs hsecs echo/Time is: %hours%:%mins%:%secs%.%hsecs% goto :EOF ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :GetTime hh nn ss tt :: :: By: Ritchie Lawrence, updated 2002-10-30. Version 1.2 :: :: Func: Loads local system time components into args 1 to 4. For NT4/2K/XP :: :: Args: %1 Var to receive hours, 2 digits, 00 to 23 (by ref) :: %2 Var to receive minutes, 2 digits, 00 to 59 (by ref) :: %3 Var to receive seconds, 2 digits, 00 to 59 (by ref) :: %4 Var to receive centiseconds, 2 digits, 00 to 99 (by ref) ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: setlocal ENABLEEXTENSIONS for /f "tokens=5-8 delims=:. " %%a in ('echo/^|time') do ( set hh=%%a&set nn=%%b&set ss=%%c&set cs=%%d) if 1%hh% LSS 20 set hh=0%hh% endlocal&set %1=%hh%&set %2=%nn%&set %3=%ss%&set %4=%cs%&goto :EOF ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: @echo off&setlocal call :MonthName %1 month echo/%month% goto :EOF ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :MonthName %mm% month :: :: By: Ritchie Lawrence, 2002-10-04. Version 1.0 :: :: Func: Returns the name of month from the number of the month. :: For NT4/2K/XP :: :: Args: %1 month number convert to name of month, 1 or 01 to 12 (by val) :: %2 var to receive name of month (by ref) ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: setlocal ENABLEEXTENSIONS&set /a m=100%1%%100 for /f "tokens=%m%" %%a in ('echo/January February March April May June^ July August September October November December' ) do endlocal&set %2=%%a&goto :EOF :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::