home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / qwik32.zip / INSTALL.CMD next >
OS/2 REXX Batch file  |  1994-02-08  |  8KB  |  250 lines

  1. /******************************************************************
  2.  * Copyright Notice:                                           *
  3.  *  (c) Copyright 1993 BitWare Consulting  ALL RIGHTS RESERVED.   *
  4.  *  You may not create derived works from this material.           *
  5.  ******************************************************************
  6.  * Name:           INSTALL.CMD                            *
  7.  * Date:        1993/07/01                                 *
  8.  *                                                             *
  9.  * Description:    REXX script to install QwikSwitch.              *
  10.  *                                                             *
  11.  * Usage:          INSTALL <FromDir> <ToDir>                   *
  12.  *                                                            *
  13.  * Example:        INSTALL            or                          *
  14.  *                 INSTALL A: D:\QWKSWTCH                        *
  15.  ******************************************************************
  16. */
  17.  
  18. /* Register with REXX API extensions. */
  19. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  20. Call SysLoadFuncs
  21.  
  22. Call SysCls
  23. Say
  24. Say '                           QwikSwitch Install!'
  25. Say
  26.  
  27. /* Get command line parameters. */
  28. Parse Arg FloppyDir InstallDir 
  29. If FloppyDir = '' & InstallDir = '' then Do
  30.     Say 'Format of INSTALL.CMD is:'
  31.     Say 
  32.     Say 'INSTALL <SourceDirectory> <TargetDirectory>'
  33.     Say 'defaults  A:                C:\QWKSWTCH'
  34.     Say 
  35.     End
  36. If FloppyDir = '' Then FloppyDir = 'A:'
  37. If InstallDir = '' Then InstallDir = 'C:\QWKSWTCH'
  38.  
  39. /* Initializations. */
  40. bInstructed = 0                /* instructed before flag */
  41. Signal On Halt Name SignalHandler
  42. Signal On Error Name SignalHandler
  43. Signal On Failure Name SignalHandler
  44.  
  45. /* Fix up path. */
  46. If SubStr( FloppyDir, Length( FloppyDir ), 1 ) \= '\' Then
  47.     FloppyDir = FloppyDir||'\'
  48.  
  49. /* Confirm choices. */
  50. Say
  51. Say 'QwikSwitch will be installed with the following information:'
  52. Say
  53. Say '         Source Directory:       "'FloppyDir'"'
  54. Say '         Installation Directory: "'InstallDir'"'
  55. Say
  56. Call YNPrompt 'OK to continue?', '1'
  57.  
  58. /* Check for directory. */
  59. Say
  60. Say 'Checking for directory "'InstallDir'".'
  61. Call SysFileTree InstallDir, FileStem, 'D'
  62.  
  63. /* Directory not found. */
  64. If FileStem.0 = '0' Then Do
  65.     Say 'The "'InstallDir'" directory does not exist on your hard drive.'
  66.     Call YNPrompt 'OK to create "'InstallDir'"?', '1'
  67.     Say 'Creating 'InstallDir'....'
  68.     rc = SysMkDir( InstallDir )
  69.     if rc = 0 Then
  70.         Say 'The "'InstallDir'" directory was created successfully.'
  71.     Else Do
  72.         Say 'The "'InstallDir'" directory could not be created.'
  73.         Exit
  74.         End
  75.     End
  76.  
  77. /* Copy files. */
  78. Call SysCls
  79. Say
  80. Say 'QwikSwitch INSTALL is copying files to your hard drive.'
  81. Call CopyFile 'readme.txt',     FloppyDir, InstallDir
  82. Call CopyFile 'qwik*.*',        FloppyDir, InstallDir
  83. Call CopyFile '*.WAV',        FloppyDir, InstallDir
  84.  
  85. /* Do we need to change the programs for OS/2 2.0? 
  86.  call RxFuncAdd 'SysOS2Ver', 'RexxUtil', 'SysOS2Ver'
  87.  ver = SysOS2Ver()
  88.  ver = substr(ver,1,3)
  89.  if ver = '2.0' then Call CopyFile '*',FloppyDir'OS2_20\', InstallDir
  90.  else nop
  91. */
  92.  
  93. /* Prompt to create a program object. */
  94. Call SysCls
  95. Say 'QwikSwitch can be installed as a program object on your desktop.'
  96. Ret = YNPrompt( 'Do you want a program object created?', '0' )
  97. If Ret = 'Y' | Ret = 'y' Then Do
  98.     Say 'Creating program reference object.'
  99.     Say
  100.     r = SysCreateObject("WPProgram",,
  101.         "QwikSwitch",,
  102.         "<WP_DESKTOP>",,
  103. "EXENAME="||InstallDir||"\QWIK32.EXE;MINWIN=HIDE;STARTUPDIR="||InstallDir,,
  104.         "replace")
  105.    End
  106.  
  107. Say 'QwikSwitch has a TSR that needs to be started for DOS sessions,'
  108. Say 'We can update your C:\AUTOEXEC.BAT file now, or you can do it later.'
  109. Ret = YNPrompt( 'Should we update your AUTOEXEC.BAT now?', '0' )
  110. If Ret = 'Y' | Ret = 'y' Then Do
  111.     Say 'time to update'
  112.     call lineout 'c:\autoexec.BAT',InstallDir||'\QWIKTSR.EXE'
  113.     call lineout
  114.     end
  115.  
  116. /* Salutation! */
  117. Call SysCls
  118. Say 'QwikSwitch has been installed on your system.'
  119. Say
  120. Say 'Be sure to browse the "README.TXT" file for information about'
  121. Say 'last minute changes to the documentation.'
  122. Say
  123. Call SimplePrompt 'Press the Enter key to exit installation....'
  124. Pull ByeBye
  125. Call SysCls
  126. /* Bye! */
  127. Exit
  128.  
  129.  
  130. /**********************************************************
  131.  * Name:        CopyFile
  132.  *
  133.  * Description: Procedure to copy a file from one place to another.
  134.  *
  135.  * Args:        File2copy, FloppyDrive, DestDrive
  136.  **********************************************************
  137. */
  138. CopyFile: Arg ArgFile2Copy, ArgFloppyDir, ArgInstallDir
  139.  
  140.     Say
  141.     Say 'Copying 'ArgFloppyDir||ArgFile2Copy' to 'ArgInstallDir||'\'||ArgFile2Copy'.'
  142.     Command = '@Copy 'ArgFloppyDir||ArgFile2Copy' 'ArgInstallDir||'\'||ArgFile2Copy
  143.     Command
  144.     if rc <> 0 Then Do
  145.        Call SimplePrompt 'Error! 'ArgFile2Copy' was not installed properly.'
  146.        Pull ConfirmIt
  147.        End
  148.     Return
  149.  
  150. /**********************************************************
  151.  * Name:        SimplePrompt
  152.  *
  153.  * Description: Procedure to place a prompt onto the screen a reposition the
  154.  *              cursor.
  155.  *
  156.  * Args:        Prompt
  157.  **********************************************************
  158. */
  159. SimplePrompt: Parse Arg ArgPrompt
  160.  
  161.     /* Get current cursor position. */
  162.     Parse Value SysCurPos() With Row .
  163.  
  164.     /* Get screen size. */
  165.     Parse Value SysTextScreenSize() With NumRows .
  166.  
  167.     /* At end of screen? */
  168.     if Row = NumRows - 1 Then Row = Row - 1
  169.  
  170.     /* Assemble prompt. */
  171.     Col = Length( ArgPrompt ) + 1
  172.  
  173.     /* Show prompt. */
  174.     Say ArgPrompt
  175.     Call SysCurPos Row, Col
  176.  
  177.     Return
  178.  
  179.  
  180. /**********************************************************
  181.  * Name:        YNPrompt
  182.  *
  183.  * Description: Procedure to prompt for Yes or No.
  184.  *              Exit program if No is pressed and Abort is '1'.
  185.  *
  186.  * Args:        Yes/No Prompt
  187.  **********************************************************
  188. */
  189. YNPrompt: Parse Arg ArgPrompt, ArgAbort
  190.  
  191.     /* Prompt the user. */
  192.     Call SimplePrompt ArgPrompt' (Y or N)'
  193.  
  194.     /* Loop until user presses y or n. */
  195.     Do Forever
  196.         Key = SysGetKey( 'NOECHO' )
  197.         If Key = 'Y' | Key = 'y' Then Do
  198.            Say
  199.            Return Key
  200.            End
  201.         Else If Key = 'N' | Key = 'n' Then Do
  202.            Say
  203.            If ArgAbort = '1' Then Exit
  204.            Return Key
  205.            End
  206.        End
  207.     Return 'y'
  208.  
  209.  
  210. /**********************************************************
  211.  * Name:        Instructions
  212.  *
  213.  * Description: Instruct the user how this installation will work.
  214.  **********************************************************
  215. */
  216. Instructions:
  217.     If bInstructed  = 0 Then Do
  218.         Say
  219.         Say '                   QwikSwitch Installation Instructions:'
  220.         Say
  221.         Say
  222.         Say 'Directions:    To install QwikSwitch, you must choose a target'
  223.         Say '               directory on your hard drive and enter the name'
  224.         Say '               of the floppy drive this batch file is'
  225.         Say '               executing from.'
  226.         Say
  227.         Say 'Optional:      INSTALL <FloppyDir> <InstallDir> '
  228.         Say '               <InstallDir> defaults to C:\QWKSWTCH'
  229.         Say     
  230.         Say 'Examples:    INSTALL A: D:\UTILS\QWKSWTCH '
  231.         Say '             INSTALL A:'
  232.         bInstructed = 1
  233.         End
  234.     Else bInstructed = 0    
  235.     Return
  236.  
  237.  
  238. /****************************************************************************
  239.  * Name:        SignalHandler
  240.  *
  241.  * Description: Default signal handler.
  242.  ****************************************************************************/
  243. SignalHandler:
  244.  
  245.     Say 'QwikSwitch installation aborted.'
  246.     Exit
  247.  
  248.  
  249.  
  250.