home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
qwik32.zip
/
INSTALL.CMD
next >
Wrap
OS/2 REXX Batch file
|
1994-02-08
|
8KB
|
250 lines
/******************************************************************
* Copyright Notice: *
* (c) Copyright 1993 BitWare Consulting ALL RIGHTS RESERVED. *
* You may not create derived works from this material. *
******************************************************************
* Name: INSTALL.CMD *
* Date: 1993/07/01 *
* *
* Description: REXX script to install QwikSwitch. *
* *
* Usage: INSTALL <FromDir> <ToDir> *
* *
* Example: INSTALL or *
* INSTALL A: D:\QWKSWTCH *
******************************************************************
*/
/* Register with REXX API extensions. */
Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
Call SysLoadFuncs
Call SysCls
Say
Say ' QwikSwitch Install!'
Say
/* Get command line parameters. */
Parse Arg FloppyDir InstallDir
If FloppyDir = '' & InstallDir = '' then Do
Say 'Format of INSTALL.CMD is:'
Say
Say 'INSTALL <SourceDirectory> <TargetDirectory>'
Say 'defaults A: C:\QWKSWTCH'
Say
End
If FloppyDir = '' Then FloppyDir = 'A:'
If InstallDir = '' Then InstallDir = 'C:\QWKSWTCH'
/* Initializations. */
bInstructed = 0 /* instructed before flag */
Signal On Halt Name SignalHandler
Signal On Error Name SignalHandler
Signal On Failure Name SignalHandler
/* Fix up path. */
If SubStr( FloppyDir, Length( FloppyDir ), 1 ) \= '\' Then
FloppyDir = FloppyDir||'\'
/* Confirm choices. */
Say
Say 'QwikSwitch will be installed with the following information:'
Say
Say ' Source Directory: "'FloppyDir'"'
Say ' Installation Directory: "'InstallDir'"'
Say
Call YNPrompt 'OK to continue?', '1'
/* Check for directory. */
Say
Say 'Checking for directory "'InstallDir'".'
Call SysFileTree InstallDir, FileStem, 'D'
/* Directory not found. */
If FileStem.0 = '0' Then Do
Say 'The "'InstallDir'" directory does not exist on your hard drive.'
Call YNPrompt 'OK to create "'InstallDir'"?', '1'
Say 'Creating 'InstallDir'....'
rc = SysMkDir( InstallDir )
if rc = 0 Then
Say 'The "'InstallDir'" directory was created successfully.'
Else Do
Say 'The "'InstallDir'" directory could not be created.'
Exit
End
End
/* Copy files. */
Call SysCls
Say
Say 'QwikSwitch INSTALL is copying files to your hard drive.'
Call CopyFile 'readme.txt', FloppyDir, InstallDir
Call CopyFile 'qwik*.*', FloppyDir, InstallDir
Call CopyFile '*.WAV', FloppyDir, InstallDir
/* Do we need to change the programs for OS/2 2.0?
call RxFuncAdd 'SysOS2Ver', 'RexxUtil', 'SysOS2Ver'
ver = SysOS2Ver()
ver = substr(ver,1,3)
if ver = '2.0' then Call CopyFile '*',FloppyDir'OS2_20\', InstallDir
else nop
*/
/* Prompt to create a program object. */
Call SysCls
Say 'QwikSwitch can be installed as a program object on your desktop.'
Ret = YNPrompt( 'Do you want a program object created?', '0' )
If Ret = 'Y' | Ret = 'y' Then Do
Say 'Creating program reference object.'
Say
r = SysCreateObject("WPProgram",,
"QwikSwitch",,
"<WP_DESKTOP>",,
"EXENAME="||InstallDir||"\QWIK32.EXE;MINWIN=HIDE;STARTUPDIR="||InstallDir,,
"replace")
End
Say 'QwikSwitch has a TSR that needs to be started for DOS sessions,'
Say 'We can update your C:\AUTOEXEC.BAT file now, or you can do it later.'
Ret = YNPrompt( 'Should we update your AUTOEXEC.BAT now?', '0' )
If Ret = 'Y' | Ret = 'y' Then Do
Say 'time to update'
call lineout 'c:\autoexec.BAT',InstallDir||'\QWIKTSR.EXE'
call lineout
end
/* Salutation! */
Call SysCls
Say 'QwikSwitch has been installed on your system.'
Say
Say 'Be sure to browse the "README.TXT" file for information about'
Say 'last minute changes to the documentation.'
Say
Call SimplePrompt 'Press the Enter key to exit installation....'
Pull ByeBye
Call SysCls
/* Bye! */
Exit
/**********************************************************
* Name: CopyFile
*
* Description: Procedure to copy a file from one place to another.
*
* Args: File2copy, FloppyDrive, DestDrive
**********************************************************
*/
CopyFile: Arg ArgFile2Copy, ArgFloppyDir, ArgInstallDir
Say
Say 'Copying 'ArgFloppyDir||ArgFile2Copy' to 'ArgInstallDir||'\'||ArgFile2Copy'.'
Command = '@Copy 'ArgFloppyDir||ArgFile2Copy' 'ArgInstallDir||'\'||ArgFile2Copy
Command
if rc <> 0 Then Do
Call SimplePrompt 'Error! 'ArgFile2Copy' was not installed properly.'
Pull ConfirmIt
End
Return
/**********************************************************
* Name: SimplePrompt
*
* Description: Procedure to place a prompt onto the screen a reposition the
* cursor.
*
* Args: Prompt
**********************************************************
*/
SimplePrompt: Parse Arg ArgPrompt
/* Get current cursor position. */
Parse Value SysCurPos() With Row .
/* Get screen size. */
Parse Value SysTextScreenSize() With NumRows .
/* At end of screen? */
if Row = NumRows - 1 Then Row = Row - 1
/* Assemble prompt. */
Col = Length( ArgPrompt ) + 1
/* Show prompt. */
Say ArgPrompt
Call SysCurPos Row, Col
Return
/**********************************************************
* Name: YNPrompt
*
* Description: Procedure to prompt for Yes or No.
* Exit program if No is pressed and Abort is '1'.
*
* Args: Yes/No Prompt
**********************************************************
*/
YNPrompt: Parse Arg ArgPrompt, ArgAbort
/* Prompt the user. */
Call SimplePrompt ArgPrompt' (Y or N)'
/* Loop until user presses y or n. */
Do Forever
Key = SysGetKey( 'NOECHO' )
If Key = 'Y' | Key = 'y' Then Do
Say
Return Key
End
Else If Key = 'N' | Key = 'n' Then Do
Say
If ArgAbort = '1' Then Exit
Return Key
End
End
Return 'y'
/**********************************************************
* Name: Instructions
*
* Description: Instruct the user how this installation will work.
**********************************************************
*/
Instructions:
If bInstructed = 0 Then Do
Say
Say ' QwikSwitch Installation Instructions:'
Say
Say
Say 'Directions: To install QwikSwitch, you must choose a target'
Say ' directory on your hard drive and enter the name'
Say ' of the floppy drive this batch file is'
Say ' executing from.'
Say
Say 'Optional: INSTALL <FloppyDir> <InstallDir> '
Say ' <InstallDir> defaults to C:\QWKSWTCH'
Say
Say 'Examples: INSTALL A: D:\UTILS\QWKSWTCH '
Say ' INSTALL A:'
bInstructed = 1
End
Else bInstructed = 0
Return
/****************************************************************************
* Name: SignalHandler
*
* Description: Default signal handler.
****************************************************************************/
SignalHandler:
Say 'QwikSwitch installation aborted.'
Exit