home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / svd118.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1996-01-18  |  13KB  |  478 lines

  1. /*
  2.  
  3. @echo off
  4. cls
  5. echo.
  6. echo This INSTALL routine requires OS/2 REXX support installed.
  7. echo Run Selective Installation from the OS/2 Setup Folder to
  8. echo install REXX support before attempting to run this CMD file.
  9. pause
  10. exit
  11.  
  12.         *---------------------------------------------------------*
  13.         |                                                         |
  14.         | INSTALL.CMD -- Install procedure for Super Virtual Disk |
  15.         |                (C) Copyright 1994-96 Albert J. Shan     |
  16.         |                All Rights Reserved                      |
  17.         |                                                         |
  18.         *---------------------------------------------------------*
  19. */
  20.  
  21. '@echo off'
  22.  
  23. BootDrive       = ''
  24. InstallPath     = ''
  25. ItemChecked.1   = ' '
  26. ItemChecked.2   = ' '
  27. ItemChecked.3   = ' '
  28. ItemChecked.4   = ' '
  29. InstallList.0   = 'INSTALL.CMD'
  30. InstallList.1   = 'SVDISK.SYS'
  31. InstallList.2   = 'SVDC.EXE'
  32. InstallList.3   = 'PMSVDC.EXE'
  33. InstallList.4   = 'HFORMAT.EXE'
  34. InstallList.5   = 'HMOUNT.EXE'
  35. InstallList.6   = 'REREGSVD.EXE'
  36. InstallList.7   = 'XDFSVD.EXE'
  37. InstallList.8   = 'KWIKTOOL.ENG'
  38. InstallList.9   = 'SVDISK.ENG'
  39. InstallList.10  = 'PMSVDC.ENG'
  40. InstallList.11  = 'HFORMAT.ENG'
  41. InstallList.12  = 'HMOUNT.ENG'
  42. InstallList.13  = 'XDFSVD.ENG'
  43. InstallList.14  = 'KWIKTOOL.GER'
  44. InstallList.15  = 'SVDISK.GER'
  45. InstallList.16  = 'PMSVDC.GER'
  46. InstallList.17  = 'HFORMAT.GER'
  47. InstallList.18  = 'HMOUNT.GER'
  48. InstallList.19  = 'XDFSVD.GER'
  49. InstallList.20  = 'SVDISK.DOC'
  50. InstallList.21  = 'SVDISK.HST'
  51. InstallList.22  = 'LICENSE.DOC'
  52. InstallList.23  = 'WARRANTY.DOC'
  53. InstallList.24  = 'ORDER.FRM'
  54. InstallList.25  = 'README'
  55. InstallList.26  = 'FILE_ID.DIZ'
  56. InstallList.27  = ''
  57. MessageFile.0   = 'PMSVDC'
  58. MessageFile.1   = 'KWIKTOOL'
  59. MessageFile.2   = 'SVDISK'
  60. MessageFile.3   = 'HFORMAT'
  61. MessageFile.4   = 'HMOUNT'
  62. MessageFile.5   = 'XDFSVD'
  63. MessageFile.6   = ''
  64. CopyrightLine1  = 'Install procedure for Super Virtual Disk V1.18'
  65. CopyrightLine2  = '(C) Copyright 1994-96 Albert J. Shan'
  66. CopyrightLine3  = 'All Rights Reserved'
  67.  
  68. /* Load REXXUTIL */
  69. call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  70. call sysloadfuncs
  71.  
  72. /* Check to make sure all the distribution files are found */
  73. i = 0
  74. do while InstallList.i \= ''
  75.   call SysFileTree InstallList.i, 'tmp', 'F'
  76.   if tmp.0 = 0 then do
  77.     say
  78.     say 'Cannot locate one of the distribution files.'
  79.     say 'Please make sure INSTALL.CMD is run from the'
  80.     say 'directory or drive where the distribution'
  81.     say 'files can be found.'
  82.     exit
  83.   end
  84.   i = i + 1
  85. end
  86.  
  87. AvailDrives = SysDriveMap('C:', 'LOCAL')
  88.  
  89. /* Get boot drive letter */
  90. done = 0
  91. do while \ done
  92.   call ShowCopyright
  93.   say '  Please enter the drive letter for your OS/2 boot drive.'
  94.   call charout, '  Press the letter for the drive or ESC to quit: '
  95.   do forever
  96.     k = translate(SysGetKey('NOECHO'))
  97.     if k = D2C(27) then
  98.       call InstallEnd
  99.     else do
  100.       k = k||':'
  101.       if pos(k, AvailDrives) = 0 then
  102.         call beep 1760, 50
  103.       else do
  104.         call SysFileTree k||'\Config.Sys', 'tmp', 'F'
  105.         if tmp.0 = 0 then do
  106.           say
  107.           say
  108.           say 'Cannot locate "'k'\Config.Sys"'
  109.           call PressAnyKey
  110.           leave
  111.         end
  112.         else do
  113.           BootDrive = k
  114.           done = 1
  115.           leave
  116.         end
  117.       end
  118.     end
  119.   end
  120. end
  121.  
  122. /* Check to see if Config.sys contains SVDISK.SYS.  If so, grab the path
  123.    where SVDISK.SYS is installed at. */
  124. do until lines(BootDrive||'\Config.sys') = 0
  125.   parse value linein(BootDrive||'\Config.sys') with ConfigLine
  126.   position = pos('SVDISK.SYS', strip(translate(ConfigLine)))
  127.   if position > 0 & substr(strip(translate(ConfigLine)), 1, 7) = 'DEVICE=' then do
  128.     InstallPath = substr(strip(ConfigLine), 8, position - 9)
  129.     if length(InstallPath) = 1 then
  130.       InstallPath = InstallPath||'\'
  131.   end
  132. end
  133. call lineout BootDrive||'\Config.sys'
  134.  
  135. /* main selection loop */
  136. do forever
  137.   call ShowCopyright
  138.   say 'Select one of the following:'
  139.   say
  140.   say '  ['||ItemChecked.1||'] 1. Install Super Virtual Disk'
  141.   say '  ['||ItemChecked.2||'] 2. Language (message files) selection'
  142.   say '  ['||ItemChecked.3||'] 3. Create PM SVDisk Control object on the Desktop'
  143.   say '  ['||ItemChecked.4||'] 4. Transfer registration info from a registered copy of SVDisk'
  144.   say
  145.   say '  ESC to quit'
  146.   say
  147.   call charout, 'Press 1, 2, 3, 4 or ESC: '
  148.   do forever
  149.     k = translate(SysGetKey('NOECHO'))
  150.     if k = '0' | k = D2C(27) then
  151.       call InstallEnd
  152.     else do
  153.       if k = '1' then do
  154.         call InstallFiles
  155.         leave
  156.       end
  157.       if k = '2' then do
  158.         call SelectLanguage
  159.         leave
  160.       end
  161.       if k = '3' then do
  162.         call CreatePMSVDiskObject
  163.         leave
  164.       end
  165.       if k = '4' then do
  166.         call UpgradeRegSVD
  167.         leave
  168.       end
  169.     end
  170.     call beep 1760, 50
  171.   end
  172. end
  173.  
  174. /* Main install routine */
  175. InstallFiles:
  176.   /* If CONFIG.SYS contains SVDISK.SYS, prompt for upgrade */
  177.   if InstallPath \= '' then do
  178.     call ShowCopyright
  179.     say 'An existing copy of SVDisk is found in '||InstallPath
  180.     say 'If this is a registered copy, you can use it to upgrade'
  181.     say 'the Shareware version into the registered version.'
  182.     say
  183.     call charout, 'Proceed with upgrade? (Y/N) '
  184.     do forever
  185.       k = translate(SysGetKey('NOECHO'))
  186.       if k = 'N' then
  187.         leave
  188.       if k = 'Y' then do
  189.         call UpgradeRegSVD
  190.         leave
  191.       end
  192.       call beep 1760, 50
  193.     end
  194.   end
  195.  
  196.   /* Query new installation path */
  197.   do forever
  198.     call ShowCopyright
  199.     call charout, '  Super Virtual Disk will be installed into '
  200.     if InstallPath \= '' then
  201.       say InstallPath
  202.     else say BootDrive||'\SVDisk'
  203.     say
  204.     say 'Press Enter to accept, or type in a new path where'
  205.     say 'you want to install SVDisk.'
  206.     NewPath = GetPath(NewPath)
  207.     if NewPath = '' then do
  208.       if InstallPath = '' then
  209.         NewPath = BootDrive||'\SVDisk'
  210.       else
  211.         NewPath = InstallPath
  212.     end
  213.     error = SysMkDir(NewPath)
  214.     if error \= 5 & error > 0 then do
  215.       say 'Unable to create subdirectory.'
  216.       call PressAnyKey
  217.     end
  218.     else
  219.       leave
  220.   end
  221.   /* Confirm on install */
  222.   if NewPath \= '' then do
  223.     say
  224.     say '  The new install path is: '||NewPath
  225.   end
  226.   say
  227.   call charout, 'Proceed with install? (Y/N) '
  228.   do forever
  229.     k = translate(SysGetKey('NOECHO'))
  230.     if k = 'N' then
  231.       return
  232.     if k = 'Y' then do
  233.       say
  234.       leave
  235.     end
  236.     call beep 1760, 50
  237.   end
  238.  
  239.   InstallPath = NewPath
  240.   call CopyFiles
  241.   call UpdateConfig
  242.   call SelectLanguage
  243.   call ShowCopyright
  244.   call charout, 'Create/update Desktop object for controlling SVDisk? (Y/N) '
  245.   do forever
  246.     k = translate(SysGetKey('NOECHO'))
  247.     if k = 'N' then
  248.       return
  249.     if k = 'Y' then
  250.       leave
  251.     call beep 1760, 50
  252.   end
  253.   call CreatePMSVDiskObject
  254.   return
  255.  
  256.  
  257. /* Language selection */
  258. SelectLanguage:
  259.   call QueryInstallPath
  260.   call ShowCopyright
  261.   say '  You have 2 choices for language selection.  You can select'
  262.   say '  English messages or German messages.'
  263.   say
  264.   say '  NOTE: make sure NONE of the SVDisk executable files are'
  265.   say '        running before making a selection.'
  266.   say
  267.   say '  Press E for English messages'
  268.   say '        G for German messages'
  269.   say '        ESC to quit'
  270.   error = 0
  271.   i = 0
  272.   do forever
  273.     k = translate(SysGetKey('NOECHO'))
  274.     if k = D2C(27) then return
  275.     if k = 'E' then do
  276.       EXT = '.ENG'
  277.       leave
  278.     end
  279.     if k = 'G' then do
  280.       EXT = '.GER'
  281.       leave
  282.     end
  283.     call beep 1760, 50
  284.   end
  285.   do until MessageFile.i = ''
  286.     copy InstallPath||'\'||MessageFile.i||EXT InstallPath||'\'||MessageFile.i||'.MSG' '> nul 2>nul'
  287.     if rc \=0 then
  288.       error = error + 1
  289.     i = i + 1
  290.   end
  291.   if error > 0 & error \= i*2 then do
  292.     say
  293.     say 'The language selection may not be successful.  Some'
  294.     say 'message files may be in use by one of the SVDisk'
  295.     say 'executable programs.  Please exit all SVDisk executable'
  296.     say 'programs, and make the language selection again.'
  297.     call PressAnyKey
  298.    end
  299.    else
  300.      ItemChecked.2 = 'X'
  301.   return
  302.  
  303.  
  304. /* Create PM SVDisk control on Desktop */
  305. CreatePMSVDiskObject:
  306.   call ShowCopyright
  307.   call QueryInstallPath
  308.   say
  309.   if SysCreateObject('WPProgram', 'SVDisk Control', '<WP_DESKTOP>',,
  310.        'OBJECTID=<PMSVDC>;EXENAME='||InstallPath||'\PMSVDC.EXE;'||,
  311.        'STARTUPDIR='||InstallPath||';PROGTYPE=PM;', 'U') then do
  312.     say 'Object created successfully.'
  313.     ItemChecked.3 = 'X'
  314.   end
  315.   else
  316.     say 'Failed to create object on the Desktop.'
  317.   call PressAnyKey
  318.   return
  319.  
  320.  
  321. /* Upgrade older registered version of SVDisk to this version */
  322. UpgradeRegSVD:
  323.   call ShowCopyright
  324.   reregsvd InstallPath
  325.   if rc = 0 then do
  326.     say
  327.     say 'Upgrade was successful.  Please proceed with files install.'
  328.     ItemChecked.4 = 'X'
  329.   end
  330.   call PressAnyKey
  331.   return
  332.  
  333.  
  334. /* Show copyright notice */
  335. ShowCopyright:
  336.   call SysCls
  337.   say
  338.   say
  339.   say CopyrightLine1
  340.   say CopyrightLine2
  341.   say CopyrightLine3
  342.   say
  343.   say
  344.   return
  345.  
  346.  
  347. /* Wait for a key press */
  348. PressAnyKey:
  349.   call charout, 'Press any key to continue...'
  350.   call SysGetKey 'NOECHO'
  351.   return
  352.  
  353.  
  354. /* Get path from user */
  355. GetPath:
  356.   call charout, '> '
  357.   parse pull APath
  358.   len = length(APath)
  359.   if len > 0 then
  360.     if substr(APath, len, 1) = '\' then
  361.       APath = substr(APath, 1, len-1)
  362.   return APath
  363.  
  364.  
  365. /* Query installation path if not already set */
  366. QueryInstallPath:
  367.   if InstallPath = '' then do
  368.     call ShowCopyright
  369.     say 'Enter the path where SVDisk is installed.'
  370.     InstallPath = GetPath(InstallPath)
  371.   end
  372.   return
  373.  
  374.  
  375. /* Copy distribution files to the install path */
  376. CopyFiles:
  377.   call ShowCopyright
  378.   /* Remove *.ENG, *.GER files */
  379.   i = 0
  380.   do until MessageFile.i = ''
  381.     del InstallPath||'\'||MessageFile.i||'.ENG' '> nul 2>nul'
  382.     del InstallPath||'\'||MessageFile.i||'.GER' '> nul 2>nul'
  383.     i = i + 1
  384.   end
  385.   i = 0
  386.   do until InstallList.i = ''
  387.     say '  Copying '||substr(InstallList.i, 1, 12, ' ')||' to '||InstallPath
  388.     copy InstallList.i InstallPath '> nul 2>nul'
  389.     if rc \= 0 then do
  390.       say
  391.       say 'Unable to copy '||InstallList.i||' to '||InstallPath
  392.       say 'The file may be missing or the disk may be full.'
  393.       exit
  394.     end
  395.     i = i + 1
  396.   end
  397.   return
  398.  
  399.  
  400. /* Append InstallPath to end of PATH=/DPATH= if not already in it */
  401. AppendInstallPath:
  402.   position = pos(translate(InstallPath), translate(ConfigLine))
  403.   if position = 0 then do
  404.     len = length(ConfigLine)
  405.     if substr(ConfigLine, len, 1) = ';' then
  406.       return substr(ConfigLine, 1, len)||InstallPath
  407.     else
  408.       return substr(ConfigLine, 1, len)||';'||InstallPath
  409.   end
  410.   return ConfigLine
  411.  
  412.  
  413. /* Update CONFIG.SYS for path/dpath */
  414. UpdateConfig:
  415.   FoundDevice = 0
  416.   call ShowCopyright
  417.   call charout, 'Updating '||BootDrive||'\Config.sys ... '
  418.   call linein BootDrive||'\Config.sys', 1, 0
  419.   NewConfig = SysTempFileName(BootDrive||'\Config.???')
  420.   do until lines(BootDrive||'\Config.sys') = 0
  421.     parse value linein(BootDrive||'\Config.sys') with ConfigLine
  422.     if substr(strip(translate(ConfigLine)), 1, 9) = 'SET PATH=' then
  423.       ConfigLine = AppendInstallPath(ConfigLine)
  424.     if substr(strip(translate(ConfigLine)), 1, 10) = 'SET DPATH=' then
  425.       ConfigLine = AppendInstallPath(ConfigLine)
  426.     position = pos('SVDISK.SYS', strip(translate(ConfigLine)))
  427.     if position > 0 & substr(strip(translate(ConfigLine)), 1, 7) = 'DEVICE=' then do
  428.       ConfigLine = substr(strip(ConfigLine), 1, 7)||InstallPath||,
  429.                    '\'||substr(ConfigLine, position, length(strip(ConfigLine))-position+1)
  430.       FoundDevice = 1
  431.     end
  432.     position = pos('SVDC.EXE', strip(translate(ConfigLine)))
  433.     if position > 0 & substr(strip(translate(ConfigLine)), 1, 5) = 'CALL=' then
  434.         ConfigLine = substr(strip(ConfigLine), 1, 5)||InstallPath||,
  435.                      '\'||substr(ConfigLine, position, length(strip(ConfigLine))-position+1)
  436.     call lineout NewConfig, ConfigLine
  437.   end
  438.   /* Did we process any SVDISK.SYS?  If not, add a 1.44MB VFloppy by default */
  439.   if FoundDevice = 0 then do
  440.     call lineout NewConfig, 'DEVICE='||InstallPath||'\SVDisk.sys'
  441.     len = length(AvailDrives)
  442.     SVDiskDrive = D2C(C2D(substr(AvailDrives, len-1, 1))+1)||':'
  443.     call lineout NewConfig, 'CALL='||InstallPath||'\SVDC.EXE /i '||,
  444.          SVDiskDrive
  445.   end
  446.   call lineout NewConfig
  447.   call lineout BootDrive||'\Config.sys'
  448.   del BootDrive||'\Config.svd' '> nul 2>nul'
  449.   ren BootDrive||'\Config.sys' 'Config.svd' '> nul 2>nul'
  450.   ren NewConfig 'Config.sys' '> nul 2>nul'
  451.   if rc = 0 then do
  452.     say 'success.'
  453.     ItemChecked.1 = 'X'
  454.     if FoundDevice = 0 then do
  455.       say
  456.       say 'SVDisk is being installed as '||SVDiskDrive
  457.       say
  458.     end
  459.   end
  460.   else
  461.     say 'failed.'
  462.   call PressAnyKey
  463.   return
  464.  
  465.  
  466. InstallEnd:
  467.   call SysCls
  468.   say
  469.   say
  470.   say 'Super Virtual Disk INSTALL ended.'
  471.   if ItemChecked.1 = 'X' then do
  472.     say
  473.     say 'Config.sys has been updated.  Please shutdown and reboot'
  474.     say 'for the new changes to take effect.'
  475.   end
  476.   exit
  477.  
  478.