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

  1. /***********************************************************************/
  2. /* OBJUTIL                                                             */
  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 1994                   */
  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'\DLL\OBJUTIL.DLL' Ctl.!Destination'\DLL\*.* /s /e > nul 2>nul'
  73. 'XCOPY 'Ctl.!Source'\OS2HELP\OBJUTIL.HLP' Ctl.!Destination'\OS2HELP\*.* /s /e >nul 2>nul'
  74. Resp = rc
  75. if Resp \= 0
  76.   then call MyExit 301
  77.  
  78. if \Ctl.!Quiet
  79.   then do
  80.     say '┌────────────────────────────────────────────────────────────────────────────┐'
  81.     say '│'center('Creating an instance of the Object Utility/2. Please wait...',76)'│'
  82.     say '└────────────────────────────────────────────────────────────────────────────┘'
  83.   end /* Do */
  84. do while queued() <> 0
  85.   pull .
  86. end /* do */
  87.  
  88. if SysRegisterObjectClass( 'ObjectUtility', Ctl.!Destination'\DLL\OBJUTIL.DLL')
  89.         then do
  90.         say '┌────────────────────────────────────────────────────────────────────────────┐'
  91.         say '│'center('Class Object registered successfully.', 76)'│'
  92.         say '└────────────────────────────────────────────────────────────────────────────┘'
  93.         end /* do */
  94. if SysCreateObject( 'ObjectUtility', 'Object Utility', '<DEVCON_OS2_FOLDER>', 'OBJECTID=OBJECTUTILITY', 'R')
  95.         then do
  96.         say '┌────────────────────────────────────────────────────────────────────────────┐'
  97.         say '│'center('Class Object created successfully.', 76)'│'
  98.         say '└────────────────────────────────────────────────────────────────────────────┘'
  99.         end /* do */
  100. if \Ctl.!Quiet
  101.   then do
  102.     say '┌────────────────────────────────────────────────────────────────────────────┐'
  103.     say '│'center('Installation completed successfully.', 76)'│'
  104.     say '└────────────────────────────────────────────────────────────────────────────┘'
  105.   end /* Do */
  106. return 0
  107.  
  108. PromptDestination: procedure expose (Globals)
  109. parse arg path
  110. '@ECHO OFF'
  111. do until answer = 'Y'
  112.   'cls'
  113.   say
  114.   say '┌────────────────────────────────────────────────────────────────────────────┐'
  115.   say '│                       The Developer Connection                             │'
  116.   say '│            'right(Ctl.!ProgName,20)' Installation                               │'
  117.   say '│                  (C) Copyright IBM Corporation 1994                        │'
  118.   say '└────────────────────────────────────────────────────────────────────────────┘'
  119.   say
  120.   say 'The installation path for 'Ctl.!ProgName' is 'path
  121.   say
  122.   say 'To ONLY change the drive, enter d: (where d is the new drive letter)'
  123.   say 'To ONLY change the path, enter \path (where path is the new path)'
  124.   say
  125.   say 'Enter a new destination for 'Ctl.!ProgName', hit enter for default path, or Q to QUIT:'
  126.  
  127.   tmppath = translate(linein(STDIN))
  128.   if tmppath = 'Q'
  129.     then call MyExit 300
  130.   if tmppath \= ''
  131.     then do
  132.       if (length(tmppath)=2) & (substr(tmppath,2,1)=':') then
  133.         tmppath = tmppath||substr(path,3)
  134.       else if substr(tmppath,1,1)='\' then
  135.         tmppath=substr(path,1,2)||tmppath
  136.       say
  137.       say tmppath' is the new path.  Is this correct (Yes/No)?'
  138.       answer = translate(linein(STDIN))
  139.       l1 = substr(answer, 1, 1)
  140.       do while l1 \= 'Y' & l1 \= 'N'
  141.         say beep(450,150)'Please enter Y(es) or N(o)'
  142.         answer = translate(linein(STDIN))
  143.         l1 = substr(answer, 1, 1)
  144.       end /* do */
  145.       parse value reverse(RxCadd.ProgInfo.4) with fname'\'.
  146.       RxCadd.ProgInfo.4='EXE='tmppath'\'reverse(fname)
  147.       RxCadd.ProgInfo.6='WORKDIR='tmppath
  148.       if right(tmppath,1) = '\'
  149.         then tmppath = strip(tmppath, 'T', '\')
  150.       Ctl.!Destination = tmppath
  151.     end
  152.     else return path
  153. end /* Do */
  154. return
  155.  
  156. MakeDestination: procedure expose (Globals)
  157. parse arg subdir
  158. dirty = 0
  159. '@ECHO OFF'
  160. do forever
  161.   'mkdir 'subdir' >nul 2>nul'
  162.   if rc = 0 | dirty = 1 | length(subdir) <= 2
  163.     then return rc
  164.     else do
  165.       call MakeDestination(substr(subdir,1,(lastpos('\',subdir)-1)))
  166.       Dirty = 1
  167.     end  /* Do */
  168. end /* do */
  169. return rc
  170.  
  171. MyExit: procedure expose (Globals)
  172. parse arg Resp
  173.  
  174. select
  175.   when Resp = 300 & \Ctl.!Quiet
  176.     then do
  177.       call 'MessageBox' Ctl.!ProgName, 'Installation ended by user.'
  178.     end /* Do */
  179.   when Resp = 301 & \Ctl.!Quiet
  180.     then do
  181.       call 'MessageBox' Ctl.!ProgName, 'Installation failed when copying files to 'Ctl.!Destination'.'
  182.     end /* Do */
  183.   when Resp = 302 & \Ctl.!Quiet
  184.     then do
  185.       call 'MessageBox' Ctl.!ProgName,'Could not find OS/2 2.0 Boot Drive or CD-ROM path.',
  186.                         'Make sure that INSTALL was run from the drive letter of the CD-ROM.'
  187.     end  /* Do */
  188.   when Resp = 303 & \Ctl.!Quiet
  189.     then do
  190.       call beep 250, 150
  191.       call 'MessageBox' Ctl.!ProgName, 'Could not create destination directory 'Ctl.!Destination
  192.     end  /* Do */
  193.   otherwise
  194.     nop
  195. end  /* select */
  196. if \Ctl.!NoComp
  197.   then do
  198.     call 'CaddComplete' Resp
  199.     call 'CaDDExit'
  200.   end
  201. exit Resp
  202.  
  203.  
  204. Syntax:
  205.  
  206. call beep 350, 150
  207. say
  208. say '┌────────────────────────────────────────────────────────────────────────┐'
  209. say '│  Dot not found in LIBPATH.  A dot will be automatically added to your  │'
  210. say '│  CONFIG.SYS LIBPATH entry.  The DOT is necessary for the installation  │'
  211. say '│  to find its DLL files in the current directory.                       │'
  212. say '└────────────────────────────────────────────────────────────────────────┘'
  213. '@echo off'
  214. 'call LIBADD . 'Ctl.!BDr'\CONFIG.SYS >nul 2>nul'
  215. Resp = rc
  216. if rc = 0
  217.   then do
  218.     call beep 350, 150
  219.     say
  220.     say '┌────────────────────────────────────────────────────────────────────────┐'
  221.     say '│                 REBOOT the system and try install again.               │'
  222.     say '└────────────────────────────────────────────────────────────────────────┘'
  223.   end
  224.   else do
  225.     call beep 350, 150
  226.     say
  227.     say '┌────────────────────────────────────────────────────────────────────────┐'
  228.     say '│   Unable to update CONFIG.SYS please do so manually then REBOOT.       │'
  229.     say '└────────────────────────────────────────────────────────────────────────┘'
  230.   end /* Do */
  231. exit 200
  232.  
  233. halt:
  234.  
  235. call MyExit 2
  236. return
  237.