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