Desktop Archive
November 2002 Philadelphia OS/2 SIG Presentation

We suggest that you print this page and bring the listing to the meeting. Note that printing in landscape mode may be useful because, depending on your font, some lines may be wider than your margins.

Click here to download an executable version (no line numbers).

10 /* 20 Name: BackupDesktop.CMD 30 Description:Archive desktop, short version, error handling and logging removed 40 Author: HG 50 Date: 8/13/02 60 Comment: Original by Bob Eager, 2001 http://www.tavi.co.uk/os2pages/dtbackup.html 70 Usage: Run in OS/2 CMD session 80 Arguments: None 90 Output: 100 Bugs: None 110 Fixes: None 120 */ 130 140 /* echo off */ 150 "@echo off" 160 170 /* program title */ 180 progTitle = "Archiving desktop files" 190 200 /* exception handlers */ 210 220 /* machine information */ 230 machineName = value( "HOSTNAME",, "OS2ENVIRONMENT" ) 240 250 /* directories -- must end with '\' */ 260 backupDir = "D:\Temp\" 270 tempDir = backupDir || "Temp\" 280 logDir = backupDir 290 300 /* executables and parameters */ 310 zipExe = "D:\PKZipOS2\pkzip.exe" 320 zipParm1 = "/add /path=root /attr=all /zipdate=newest" 330 zipParm2 = "/add /path=root /recurse /attr=all /zipdate=newest" 340 zipParm3 = "/add /attr=all /zipdate=newest" 350 360 /* log files */ 370 380 /* errors */ 390 numErrors = 0 400 410 /* boolean variables */ 420 false = 0 430 true = 1 440 450 /* install REXX function library */ 460 rc = RxFuncAdd( "SysLoadFuncs", "RexxUtil", "SysLoadFuncs" ) 470 if ( rc > 1 ) then do 480 numErrors = numErrors + 1 490 say "Error" rc "registering 'SysLoadFuncs'... Aborting" 500 exit 510 end 520 rc = SysLoadFuncs() 530 if ( rc <> "" ) then do 540 numErrors = numErrors + 1 550 say "Error" rc "loading 'SysLoadFuncs'... Aborting" 560 exit 570 end 580 590 /* log start of program */ 600 say progTitle 610 620 /* get boot drive */ 630 bootDrive = ToLower( left( value( "RUNWORKPLACE",,"OS2ENVIRONMENT" ), 2 )) 640 650 /* files to back up */ 660 os2File = bootDrive || "\" || "os2\os2.ini" 670 os2sysFile = bootDrive || "\" || "os2\os2sys.ini" 680 configFile = bootDrive || "\" || "config.sys" 690 autoFile = bootDrive || "\" || "autoexec.bat" 700 startupFile = bootDrive || "\" || "startup.cmd" 710 binariesFile = tempDir || "binaries.zip" 720 desktopFile = tempDir || "desktop.zip" 730 warpcenterFile = tempDir || "warpctr.zip" 740 750 /* get current date in standard format, i.e., YYYYMMDD */ 760 currDate = date( "S" ) 770 780 /* convert current date to YYMMDD */ 790 currDateBrief = right( currDate, length( currDate ) - 2 ) 800 810 /* get current time in seconds since midnight, i.e., SSSSS */ 820 currTime = time( "S" ) 830 840 /* backup filename */ 850 filename = machineName || "-Desktop-" || currDateBrief || "-" || currTime || ".zip" 860 870 /* log date and time of backup */ 880 say "Backup will be called" filename 890 900 /* create name of backup file */ 910 targetFile = backupDir || filename 920 930 /* make INI files visible */ 940 "attrib -s -h" os2File 950 "attrib -s -h" os2sysFile 960 970 /* remove existing old temporary files */ 980 rc = SysFileDelete( binariesFile ) 990 if ( rc > 2 ) then do 1000 numErrors = numErrors + 1 1010 say "Error" rc "deleting" binariesFile 1020 exit 1030 end 1040 rc = SysFileDelete( desktopFile ) 1050 if ( rc > 2 ) then do 1060 numErrors = numErrors + 1 1070 say "Error" rc "deleting" desktopFile 1080 exit 1090 end 1100 rc = SysFileDelete( warpcenterFile ) 1110 if ( rc > 2 ) then do 1120 numErrors = numErrors + 1 1130 say "Error" rc "deleting" warpcenterFile 1140 exit 1150 end 1160 1170 /* back up the INI files, CONFIG.SYS and AUTOEXEC.BAT */ 1180 zipExe zipParm1 binariesFile os2File os2sysFile configFile autoFile startupFile 1190 1200 /* back up the desktop directory */ 1210 zipExe zipParm2 desktopFile bootDrive || "\Desktop\*.*" 1220 1230 /* back up the WarpCenter configuration */ 1240 zipExe zipParm1 warpcenterFile bootDrive || "\os2\dll\dock*.cfg" bootDrive || "\os2\dll\scenter.cfg" 1250 1260 /* combine all backup files */ 1270 zipExe zipParm3 targetFile binariesFile desktopFile warpcenterFile 1280 1290 /* remove temporary files */ 1300 rc = SysFileDelete( binariesFile ) 1310 if ( rc > 2 ) then do 1320 numErrors = numErrors + 1 1330 say "Error" rc "deleting" binariesFile 1340 exit 1350 end 1360 rc = SysFileDelete( desktopFile ) 1370 if ( rc > 2 ) then do 1380 numErrors = numErrors + 1 1390 say "Error" rc "deleting" desktopFile 1400 exit 1410 end 1420 rc = SysFileDelete( warpcenterFile ) 1430 if ( rc > 2 ) then do 1440 numErrors = numErrors + 1 1450 say "Error" rc "deleting" warpcenterFile 1460 exit 1470 end 1480 1490 /* hide the INI files again */ 1500 "attrib +s +h" os2File 1510 "attrib +s +h" os2sysFile 1520 1530 /* log end of program */ 1540 endOfProgram: 1550 if ( numErrors = 0 ) then do 1560 say "Program ended normally -- no errors encountered" 1570 end 1580 else do 1590 say "Program ended --" numErrors "error(s) encountered" 1600 say "Hit [ENTER] to continue..." 1610 rc = linein() 1620 end 1630 1640 /* exit program */ 1650 exit 1660 1670 /* -------------------------------------------------------------------------*/ 1680 1690 ToLower: procedure 1700 parse arg s 1710 1720 /* return translated string */ 1730 return translate( s, xrange( "a", "z" ), xrange( "A", "Z" )) 1740