home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 30 fixes_v / 30-fixes_v.zip / p21sp.zip / DESKSAVE.CMD next >
OS/2 REXX Batch file  |  1994-06-07  |  11KB  |  383 lines

  1. /* Save Desktop Directory & INIs*/
  2. /*Copyright (c) 1993 CLEAR & SIMPLE, INC.*/
  3. Arg toDrive
  4. ECHO OFF
  5. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  6. call SysLoadFuncs
  7. if todrive\='' then do;
  8. call GetBoot
  9. call initvariables
  10. dialog=0
  11. signal NoDialog
  12. end  /* Do */
  13. dialog=1
  14. 'mode co80,28'
  15. objectName='D E S K S A V E . C M D'
  16. progid='DESKSAVE.CMD'
  17. call source
  18. call initVariables
  19. call welcome
  20. 'cls'
  21. pos=SysCurPos(0,0)
  22. say 'DESKSAVE will save the WorkPlace Shell desktop settings to a diskette.'
  23. say;say '   This will save the way your desktop looks right now!'
  24. say '    Including Shadow, Folder and Template object settings';say'    and where they are located on your desktop.'
  25. say;say;
  26. say 'Technically speaking it will save:'
  27. say;SAY GREEN;say '  1.)  The DESKTOP Directory and its sub-directories'
  28. say '  2.)  OS2.INI and OS2SYS.INI'
  29. say '  3.)  Config.sys '
  30. say;say;SAY BLUE; Say 'Label the diskette';
  31. msg.0=9
  32. msg.1= black
  33. msg.2= cr5 ' ┌─────────────────────┐'
  34. msg.3= cr5 ' │   WorkPlace Shell   │ '
  35. msg.4= cr5 ' │  DESKTOP SETTINGS   │'
  36. msg.5= cr5 ' │      SAVED          │      '
  37. msg.6= cr5 ' │                     │'
  38. msg.7= cr5 ' │   (today''s date)    │'
  39. msg.8= cr5 ' └─────────────────────┘'
  40. msg.9= blue
  41. do i =1 to msg.0
  42. say msg.i
  43. end
  44. say '';SAY GREEN;SAY'';SAY BLUE;
  45. say 'You will need a formatted, diskette.'
  46. say  '  (You may also save to a non-boot fixed disk partition)'
  47. pos=SysCurPos(25,0)
  48. SAY;SAY RED;say 'Do you wish to continue? (Y/N) ';SAY BLUE
  49. pos=SysCurPos(27,0)
  50. parse upper pull ans1 .
  51. if ans1 \= 'Y' then do
  52. say 'We will not save the DESKTOP SETTINGS now!'
  53. say ' '; say 'Press Enter to End'; pull
  54. exit
  55. end
  56. else NOP
  57. todrive = ' '
  58. CALL getBOOT
  59. say ' '
  60. say 'First, I need some information from you!'
  61. say;
  62. answer = 'N'
  63. do  While answer \= 'Y'
  64. say green;say ' Please enter the diskette/fixed disk drive letter (and directory)'
  65. SAY '(e.g., "A:"  or  "B:" or  D:\DESKSAVE ) '
  66. say ' where you want me to place the backup information.'
  67. say ' (or just press Enter for the default of "A:"):'
  68. pull todrive
  69. if todrive = ' ' then todrive = 'A:'
  70. if length(todrive)=1 then todrive=todrive':'
  71. say;say 'You entered - 'todrive;say 'Is this correct? (Y/N)'
  72. pull answer
  73. end
  74.  
  75. note.1 = 262
  76. note.2 = 423
  77. note.3 = 262
  78. note.4 = 423
  79.  
  80. if todrive='A:' | todrive='B:' then do
  81. do i=1 to 4
  82. call beep note.i,75
  83. end
  84. say red;SAY 'Please insert the DESKTOP SAVE diskette into drive 'todrive
  85. 'PAUSE'
  86. end
  87. 'cls'
  88.  
  89. NoDialog:
  90. toDrive=toDrive'\P21DSAVE'
  91. call finddesk
  92. call elimdir todrive
  93.  
  94. parse var todrive drivlet ':' rest
  95. drivlet=drivlet':'
  96. call szdisk drivlet
  97. parse var result tofree .
  98.  
  99. call howbig driveis'\'desktop
  100. parse var result desksize NumberOfFiles
  101. if desksize > tofree then do
  102. 'cls'
  103. say;say;say;say '         Your Desktop total size is 'desksize 'bytes'
  104. say '         The drive - 'drivlet' has only 'tofree' bytes free'
  105. say; say red; say '         EITHER REDUCE THE SIZE OF YOUR DESKTOP'
  106. say '                          or'
  107. say '         Direct the DESKSAVE operation to a larger DISK,'
  108. say '         diskette, or drive partition.'
  109. say;say blue; say 'Press Enter to End'
  110. pull
  111. exit
  112. end  
  113.  
  114. DIR20or21=DESKTOP
  115. RC=SysFileTree(driveis'\'DIR20or21'\*.*', 'deskdirs', 'SDO')
  116.  
  117. if dialog then do;say blue; say "Now creating a new backup of your desktop!"
  118. say blue; say '...'desktop ' now being copied';end
  119. directorywithblanks='"'driveis'\'dir20or21'\*.*"'
  120. 'xcopy' directorywithblanks todrive'\dsk21sav\*.* /E/O >NUL'
  121. restore.0 ='%1\os2\Xcopy 'todrive'\DSK21SAV\*.*' directorywithblanks' /E/O'
  122. do  k=1 to deskdirs.0
  123. directorywithblanks='"'deskdirs.k'\*.*"'
  124. 'xcopy ' directorywithblanks todrive'\DK21'k'\*.* /E/O >NUL'
  125. restore.k='%1\os2\Xcopy 'todrive'\DK21'k'\*.*' directorywithblanks' /E/O'
  126. end
  127. if dialog then do; say red;say '...the .INI files are now being copied';end
  128. "xcopy " driveis"\OS2\OS2*.INI" todrive '/t/h/o >NUL'
  129. if dialog then do; say green; say '...Config.sys is now being copied';end
  130. "copy " driveis"\CONFIG.SYS" TODRIVE"\ORIGINAL.SYS" '>NUL'
  131.  
  132. call SysFileDelete todrive'\deskrstr.cmd'
  133. OUTFILE = TODRIVE'\DESKRSTR.CMD'
  134. call lineout outfile,'rem'
  135. call lineout outfile,'rem The format is:        deskrstr  c:'
  136. call lineout outfile,'rem    Where c: is the OS/2 Drive  to receive the following files:'
  137. call lineout outfile,'rem       \OS2\OS2.INI  -  \OS2\OS2SYS.INI - and the DESKTOP directory'
  138. call lineout outfile,'rem There are several directories that have 0 files'
  139. call lineout outfile,'rem The restore is copying the Extended Attributes of those directories.'
  140. call lineout outfile,'xcopy OS2.INI %1\OS2\OS2.INI /t/h/o'
  141. call lineout outfile,'xcopy OS2SYS.INI %1\OS2\OS2SYS.INI /t/h/o'
  142. call lineout outfile,restore.0
  143. do i = 1 to deskdirs.0
  144. call lineout outfile,restore.i
  145. end
  146. if dialog then do; say blue;say
  147. Say 'You just saved a copy of your Workplace Shell Desktop'
  148. Say '  To restore this copy you must boot OS/2 from a diskette'
  149. Say '  You may use the OS/2 Install Diskette & OS/2 Diskette #1'
  150. Say "  or a diskette made from Performance 2.1's OS2BOOT."
  151. say;
  152. say '  After the diskette boot change to drive & directory'
  153. say red;say;say '      'todrive
  154. say;say blue;say '  Then enter DESKRSTR c:'
  155. say; say '            where c: is your OS/2 Boot Drive'
  156.  
  157. say;say red; say 'Press Enter to end.'
  158. pull; end
  159. exit
  160.  
  161. elimdir:
  162. arg deaddir .
  163.  
  164. newdir=RXQUEUE("Create", 'elimdirQ')
  165. rc=RXQUEUE("Set", 'elimdirQ')
  166. do queued()
  167.    pull
  168. end /* do */
  169. dirs.0=0
  170. rc=SysFileTree(deaddir'\*.*',dirs,'BS', '*****', '-----')
  171. if dirs.0=0 then do; RC=RXQUEUE('Delete', 'elimdirQ'); return; end
  172. if dialog then do; say red; say "Now deleting the old saved desktop!";end
  173. do i=1 to dirs.0
  174. parse var dirs.i day time size att file
  175.    push att file;
  176. end 
  177.  
  178. do Queued()
  179. pull att file;
  180. if pos('D', att) = 2 then 'RD' file
  181. else 'del' file '/N'
  182. end 
  183.  
  184. 'RD' DEADDIR
  185. RC=RXQUEUE('Delete', newdir)
  186. return
  187.  
  188.  
  189. finddesk:
  190. ctr=0
  191. rc=SysFileTree(Driveis'\*.*',dirs,'D')
  192.  
  193. do i=1 to dirs.0
  194. parse upper var dirs.i date time . . directory
  195. directory=strip(directory,'L')
  196. parse var directory driv'\' dname
  197. parse var dname first rest
  198.  
  199. If left(first,3) = 'OS!' | left(first,7) = 'DESKTOP' then do;
  200.  
  201.  ctr=ctr+1
  202.  found.ctr=dname
  203.  birthdate.ctr=date '-' time
  204.  
  205. end 
  206. else nop
  207. end
  208. if ctr=1 then do; desktop=found.ctr;  end
  209. else call multidesk
  210. return
  211.  
  212. multidesk:
  213. say 'There are multiple directories that seem to be desktops on your boot drive'
  214. say 'Their names are:'
  215. say '#    Directory      ';say red
  216. do j=1 to ctr
  217. say j '   '  driveis'\'found.j ' Created Date/Time -  'birthdate.j
  218. end 
  219. say blue;say 'Please specify which is your current desktop by entering the number'
  220. say '  that precedes the correct desktop name.  e.g. 1  2  3  '
  221. pull numb
  222. say 'The desktop you have chosen is 'found.numb
  223. say ' If this is not correct then cancel this program (ctrl-break) and restart '
  224. say '  '
  225. say;say '  Press Enter to continue...'
  226. pull
  227. desktop=found.numb
  228. return
  229.  
  230.  
  231. howbig:
  232. arg hbdir
  233.  
  234. newq= RXQUEUE('create')
  235. oq=RXQUEUE('Set', newq)
  236. hbtot=0;hbfilect=0
  237. 'Dir ' hbdir '/s/n/o:-d | rxqueue 'newq
  238. do until queued() = 0
  239. entry=lineIN('Queue:')
  240. parse var entry filedate ftime fsize easize name
  241. name=strip(name,L)
  242. fmo='';fday='';fyr='';
  243. parse upper var filedate fmo '-' fday '-' fyr;
  244. if fyr ='' then do;
  245.  if translate(filedate)='DIRECTORY'  then  hbdir=fsize
  246. iterate
  247.  end 
  248. if fyr \='' then do;
  249.  
  250.  if datatype(fsize,N) then do;
  251.  hbtot=hbtot+fsize+easize;
  252.  hbfilect=hbfilect+1
  253.  dirs.hbfilect='"'hbdir'\'name'"'
  254.  filename.hbfilect=name;
  255.  filesize.hbfilect=fsize+easize
  256. end 
  257.  else hbtot=hbtot+easize
  258. end
  259. else call dirsearch 
  260.  end 
  261. rc=rxqueue('delete', newQ)
  262. dirs.0=hbfilect
  263. return hbtot hbfilect
  264.  
  265. dirsearch:
  266. do until strip(filedate)='DIRECTORY' | queued()=0
  267. entry=lineIN('Queue:')
  268. parse upper var entry filedate ftime fsize easize name;
  269. if strip(filedate)='DIRECTORY'  then  hbdir=fsize
  270. end
  271. return
  272.  
  273. source:
  274. parse upper source where
  275. parse var where . . yes'\DESKSAVE.CMD'
  276. rc=SysFileTree(yes'\MAP.CMD', stem, F)
  277. if stem.0=0 then DO;
  278. SAY 'This program has been modified to ONLY execute from the same'
  279. say 'location where the entire Performance 2.1 PLUS product is installed.'
  280. say 'We created this inconvience so that we could make it more '
  281. say 'convienient to distribute this update over CompuServe.'
  282. say;say 'Please copy this program 'progid 'to the correct drive'
  283. say 'and directory where Performance 2.1 PLUS is installed, \PERF21 '
  284. say '- so that it will properly execute.'
  285. say; say 'If you do not have Performance 2.1 PLUS you may '
  286. say 'purchase it from several stores that carry OS/2 Software.  '
  287. say 'You can also call Clear & Simple, Inc. at 203-658-1204, '
  288. say 'or Fax (203) 651-0354, we accept VISA, MC or Discover credit cards.'
  289. say;say 'The price of Performance 2.1 PLUS is only $39.95 '
  290. say '- it includes a 100 page book dedicated to tuning your OS/2 system,'
  291. say 'and 40 REXX utility programs that simplify the tuning process'
  292. say 'and provide additional utility functions like backing-up your desktop'
  293. say 'or making a single OS/2 Boot Diskette, etc.'
  294. say;say 'Press enter to end.'
  295. pull
  296. exit
  297. end  
  298. return
  299.  
  300.  
  301. getBOOT:
  302. bootdrive = Value('Path',,'OS2ENVIRONMENT')
  303. parse upper var bootdrive bootdrive
  304. Driveis = Substr(bootdrive,Pos('\OS2\SYSTEM',bootdrive)-2,2)
  305. return
  306. Welcome:
  307. echo on
  308. 'prompt $p$E[0;'34';'47';'5';'5'm]'
  309. echo off
  310. 'cls'
  311. call SysCurState 'OFF'
  312. call sysCurPos '4', '0'
  313. msg.0 =12
  314. msg.1 = blue
  315. msg.2 = cr5 cr5' ┌────────────────────────────────┐'
  316. msg.3 = cr5 cr5' │                                │ '
  317. msg.4 = cr5 cr5' │  P E R F O R M A N C E   2.1   │'
  318. msg.5 = cr5 cr5' │                                │      '
  319. msg.6 = cr5 cr5' │                                │'
  320. msg.7 = cr5 cr5' │                                │'
  321. msg.8 = cr5 cr5' │                                │'
  322. msg.9 = cr5 cr5' │                                │'
  323. msg.10 = cr5 cr5' └────────────────────────────────┘'
  324. msg.11 = hblue
  325. msg.12 = cr5 '        Copyright (c) 1993 Clear & Simple, Inc.           '
  326. do i =1  to msg.0
  327. say msg.i
  328. end
  329. call SysCurPos '19','0'
  330. say red;
  331. call sysCurPos '7', '22'
  332. call syssay '────────────────────────────'
  333. call sysCurPos '8', '21'
  334. call syssay '─────────────────────────────'
  335. say;
  336. say red;
  337. call sysCurPos '9', '21'
  338. call syssay 'Go'
  339. call sysCurPos '9', '23'
  340. call syssay ' as fast as'
  341. call sysCurPos '9', '35'
  342. call syssay '32 bits'
  343. call sysCurPos '11', '30'
  344. call syssay ' will'
  345. call sysCurPos '11', '35'
  346. call syssay ' take'
  347. say blue;
  348. call sysCurPos '11', '41'
  349. call syssay 'you!'
  350. say hblack;
  351. call sysCurPos '15', '0'
  352. SAY'       Please Maximize SCREEN SIZE  & Press Enter to Continue...'
  353. say red;
  354. call sysCurPos '14', '26'
  355. CALL SYSPAUSE ObjectName
  356. call SysCurState 'ON'
  357. 'cls'
  358. echo on
  359. 'prompt $p$E[0;'34';'47';'5';'5'm]'
  360. echo off
  361. 'cls'
  362. return
  363. InitVariables:
  364. black      ='A'
  365. red        ='A'
  366. green      ='A'
  367. blue       ='A'
  368. hblack      ='A'
  369. hblue      ='A'
  370. cr5 ='C'
  371. return
  372. SysPause:
  373. parse arg prompt
  374. call SysSay prompt
  375. pos=SysCurPos(0,0)
  376. Pull .
  377. say
  378. return
  379. SysSay:
  380. parse arg string
  381. call charout 'STDOUT', string
  382. return
  383.