home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / install / sampinst.cmd < prev    next >
Encoding:
Text File  |  1994-03-01  |  10.4 KB  |  264 lines

  1. /***********************************************************************/
  2. /* SAMPINST.CMD                                                        */
  3. /*                                                                     */
  4. /* Purpose: Uses XCOPY to install all files from a sub directory       */
  5. /*          into a user specified destination directory.               */
  6. /*                                                                     */
  7. /* Parameters: BootDrive: Drive letter where system boots              */
  8. /*             Install Drive: Drive letter and path of CDROM           */
  9. /*             Program Name: Name of the program to install.           */
  10. /*             Source:       Directory where program is located.       */
  11. /*             Destination:  Default installation directory.           */
  12. /*             Options: any options                                    */
  13. /***********************************************************************/
  14. /*                (C) Copyright IBM Corporation 1993                   */
  15. /***********************************************************************/
  16. parse upper arg Ctl.!BDr Ctl.!CDr Ctl.!ProgName Ctl.!Source Ctl.!Destination Ctl.!Options
  17. trace 'o'
  18. call on halt
  19. Globals = 'Ctl.' 'RXCADD.'
  20.  
  21. call Initialize
  22.  
  23. if RxCaDD.OpType = 'REMOVE'
  24.   then do
  25.     call 'MessageBox' Ctl.!ProgName, 'Remove is not supported.  Add the application',
  26.          'again to recreate the program object.'
  27.     call 'CaDDExit'
  28.     exit 0
  29.   end  /* Do */
  30.  
  31. if substr(Ctl.!BDr,2,1) <> ':' | substr(Ctl.!CDr,2, 1) <> ':'
  32.   then call MyExit 302
  33. if \Ctl.!Quiet
  34.   then call PromptDestination Ctl.!Destination
  35. Resp = MakeDestination(Ctl.!Destination)
  36. Ctl.!CurDir = directory()
  37. temp = directory(Ctl.!Destination)
  38. if temp <> Ctl.!Destination
  39.   then call MyExit 303
  40. call directory(Ctl.!CurDir)
  41. call CopyFiles
  42. call MyExit 0
  43. exit
  44.  
  45. Initialize: procedure expose (Globals)
  46. CurDir = directory()
  47. call directory Ctl.!CDr'INSTALL'
  48. call Rxfuncadd 'CADDINIT', 'RXCADD', 'CADDINIT'
  49. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  50. Call SysLoadFuncs
  51. signal on syntax
  52. ver = 'CAddInit'()
  53. signal off syntax
  54. if abbrev(ver, 'ERROR:')
  55.   then call syntax
  56. Ctl.!Valid = 0
  57. Ctl.!Quiet = (wordpos('/N', Ctl.!Options) <> 0)
  58. Ctl.!NoComp = (wordpos('/C', Ctl.!Options) <> 0)
  59. return 0
  60.  
  61. CopyFiles: procedure expose (Globals)
  62. '@ECHO OFF'
  63. if \Ctl.!Quiet
  64.   then do
  65.     say '┌────────────────────────────────────────────────────────────────────────────┐'
  66.     say '│'center('Copying files for 'Ctl.!Progname' Please wait...',76)'│'
  67.     say '└────────────────────────────────────────────────────────────────────────────┘'
  68.   end /* Do */
  69. do while queued() <> 0
  70.   pull .
  71. end /* do */
  72. 'XCOPY 'Ctl.!Source'\*.*' Ctl.!Destination'\*.* /s /e >nul 2>nul'
  73. 'MKDIR 'Ctl.!Destination'\OS2LIB 2>NUL'
  74.  
  75. /* Register the class with the Workplace Shell                   */
  76. if SysRegisterObjectClass( 'Browse_O_Matic', Ctl.!Destination'\BROWSE\BROWSE.DLL')
  77.         then do
  78.         say '┌────────────────────────────────────────────────────────────────────────────┐'
  79.         say '│'center('Browse_O_Matic class registered sucessfully.', 76)'│'
  80.         say '└────────────────────────────────────────────────────────────────────────────┘'
  81.         end /* do */
  82.         else say 'Error registering the Browse_O_Matic class.'
  83. /* Create an object instance of the class                        */
  84. if SysCreateObject( 'Browse_O_Matic', 'Browse-O-Matic', '<DEVCON_OS2_FOLDER>', 'OBJECTID=BROWSE001', 'R')
  85.         then do
  86.         say '┌────────────────────────────────────────────────────────────────────────────┐'
  87.         say '│'center('Browse-O-Matic instance created sucessfully.', 76)'│'
  88.         say '└────────────────────────────────────────────────────────────────────────────┘'
  89.         end /* do */
  90.         else say 'Error creating Browse-O-Matic instance.'
  91.  
  92. /* Register the class with the Workplace Shell                   */
  93. if SysRegisterObjectClass( 'TextFolder', Ctl.!Destination'\TEXTFLDR\TEXTFLDR.DLL')
  94.         then do
  95.         say '┌────────────────────────────────────────────────────────────────────────────┐'
  96.         say '│'center('TextFolder class registered sucessfully.', 76)'│'
  97.         say '└────────────────────────────────────────────────────────────────────────────┘'
  98.         end /* do */
  99.         else say 'Error registering the TextFolder class.'
  100.  
  101. /* Create an object instance of the class                        */
  102. if SysCreateObject( 'TextFolder', 'TextOnlyFolder', '<DEVCON_OS2_FOLDER>', 'OBJECTID=TEXTFLDR001', 'R')
  103.         then do
  104.         say '┌────────────────────────────────────────────────────────────────────────────┐'
  105.         say '│'center('TextFolder instance created sucessfully.', 76)'│'
  106.         say '└────────────────────────────────────────────────────────────────────────────┘'
  107.         end /* do */
  108.         else say 'Error creating TextFolder instance.'
  109.  
  110. /* Register the class with the Workplace Shell                   */
  111. if SysRegisterObjectClass( 'WPSTutorial', Ctl.!Destination'\WPSTUTOR\WPSTUTOR.DLL')
  112.         then do
  113.         say '┌────────────────────────────────────────────────────────────────────────────┐'
  114.         say '│'center('WPSTutorial class registered sucessfully.', 76)'│'
  115.         say '└────────────────────────────────────────────────────────────────────────────┘'
  116.         end /* do */
  117.         else say 'Error registering the WPSTutorial class.'
  118.  
  119. /* Create an object instance of the class                        */
  120. if SysCreateObject( 'WPSTutorial', 'WPSTutorial', '<DEVCON_OS2_FOLDER>', 'OBJECTID=WPSTUT001', 'R')
  121.         then do
  122.         say '┌────────────────────────────────────────────────────────────────────────────┐'
  123.         say '│'center('WPSTutorial instance created sucessfully.', 76)'│'
  124.         say '└────────────────────────────────────────────────────────────────────────────┘'
  125.         end /* do */
  126.         else say 'Error creating WPSTutorial instance.'
  127. if \Ctl.!Quiet
  128.   then do
  129.     say '┌────────────────────────────────────────────────────────────────────────────┐'
  130.     say '│'center('Installation completed successfully.', 76)'│'
  131.     say '└────────────────────────────────────────────────────────────────────────────┘'
  132.   end /* Do */
  133. return 0
  134.  
  135. PromptDestination: procedure expose (Globals)
  136. parse arg path
  137. '@ECHO OFF'
  138. do until answer = 'Y'
  139.   'cls'
  140.   say
  141.   say '┌────────────────────────────────────────────────────────────────────────────┐'
  142.   say '│                       The Developer Connection                             │'
  143.   say '│            'right(Ctl.!ProgName,20)' Installation                               │'
  144.   say '│                  (C) Copyright IBM Corporation 1994                        │'
  145.   say '└────────────────────────────────────────────────────────────────────────────┘'
  146.   say
  147.   say 'The installation path for 'Ctl.!ProgName' is 'path
  148.   say
  149.   say 'To ONLY change the drive, enter d: (where d is the new drive letter)'
  150.   say 'To ONLY change the path, enter \path (where path is the new path)'
  151.   say
  152.   say 'Enter a new destination for 'Ctl.!ProgName', hit enter for default path, or Q to QUIT:'
  153.  
  154.   tmppath = translate(linein(STDIN))
  155.   if tmppath = 'Q'
  156.     then call MyExit 300
  157.   if tmppath \= ''
  158.     then do
  159.       if (length(tmppath)=2) & (substr(tmppath,2,1)=':') then
  160.         tmppath = tmppath||substr(path,3)
  161.       else if substr(tmppath,1,1)='\' then
  162.         tmppath=substr(path,1,2)||tmppath
  163.       say
  164.       say tmppath' is the new path.  Is this correct (Yes/No)?'
  165.       answer = translate(linein(STDIN))
  166.       l1 = substr(answer, 1, 1)
  167.       do while l1 \= 'Y' & l1 \= 'N'
  168.         say beep(450,150)'Please enter Y(es) or N(o)'
  169.         answer = translate(linein(STDIN))
  170.         l1 = substr(answer, 1, 1)
  171.       end /* do */
  172.       parse value reverse(RxCadd.ProgInfo.4) with fname'\'.
  173.       RxCadd.ProgInfo.4='EXE='tmppath'\'reverse(fname)
  174.       RxCadd.ProgInfo.6='WORKDIR='tmppath
  175.       if right(tmppath,1) = '\'
  176.         then tmppath = strip(tmppath, 'T', '\')
  177.       Ctl.!Destination = tmppath
  178.     end
  179.     else return path
  180. end /* Do */
  181. return
  182.  
  183. MakeDestination: procedure expose (Globals)
  184. parse arg subdir
  185. dirty = 0
  186. '@ECHO OFF'
  187. do forever
  188.   'mkdir 'subdir' >nul 2>nul'
  189.   if rc = 0 | dirty = 1 | length(subdir) <= 2
  190.     then return rc
  191.     else do
  192.       call MakeDestination(substr(subdir,1,(lastpos('\',subdir)-1)))
  193.       Dirty = 1
  194.     end  /* Do */
  195. end /* do */
  196. return rc
  197.  
  198. MyExit: procedure expose (Globals)
  199. parse arg Resp
  200.  
  201. select
  202.   when Resp = 300 & \Ctl.!Quiet
  203.     then do
  204.       call 'MessageBox' Ctl.!ProgName, 'Installation ended by user.'
  205.     end /* Do */
  206.   when Resp = 301 & \Ctl.!Quiet
  207.     then do
  208.       call 'MessageBox' Ctl.!ProgName, 'Installation failed when copying files to 'Ctl.!Destination'.'
  209.     end /* Do */
  210.   when Resp = 302 & \Ctl.!Quiet
  211.     then do
  212.       call 'MessageBox' Ctl.!ProgName,'Could not find OS/2 2.0 Boot Drive or CD-ROM path.',
  213.                         'Make sure that INSTALL was run from the drive letter of the CD-ROM.'
  214.     end  /* Do */
  215.   when Resp = 303 & \Ctl.!Quiet
  216.     then do
  217.       call beep 250, 150
  218.       call 'MessageBox' Ctl.!ProgName, 'Could not create destination directory 'Ctl.!Destination
  219.     end  /* Do */
  220.   otherwise
  221.     nop
  222. end  /* select */
  223. if \Ctl.!NoComp
  224.   then do
  225.     call 'CaddComplete' Resp
  226.     call 'CaDDExit'
  227.   end
  228. exit Resp
  229.  
  230.  
  231. Syntax:
  232.  
  233. call beep 350, 150
  234. say
  235. say '┌────────────────────────────────────────────────────────────────────────┐'
  236. say '│  Dot not found in LIBPATH.  A dot will be automatically added to your  │'
  237. say '│  CONFIG.SYS LIBPATH entry.  The DOT is necessary for the installation  │'
  238. say '│  to find its DLL files in the current directory.                       │'
  239. say '└────────────────────────────────────────────────────────────────────────┘'
  240. '@echo off'
  241. 'call LIBADD . 'Ctl.!BDr'\CONFIG.SYS >nul 2>nul'
  242. Resp = rc
  243. if rc = 0
  244.   then do
  245.     call beep 350, 150
  246.     say
  247.     say '┌────────────────────────────────────────────────────────────────────────┐'
  248.     say '│                 REBOOT the system and try install again.               │'
  249.     say '└────────────────────────────────────────────────────────────────────────┘'
  250.   end
  251.   else do
  252.     call beep 350, 150
  253.     say
  254.     say '┌────────────────────────────────────────────────────────────────────────┐'
  255.     say '│   Unable to update CONFIG.SYS please do so manually then REBOOT.       │'
  256.     say '└────────────────────────────────────────────────────────────────────────┘'
  257.   end /* Do */
  258. exit 200
  259.  
  260. halt:
  261.  
  262. call MyExit 2
  263. return
  264.