home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
belongs2.zip
/
B2Inst.Cmd
next >
Wrap
OS/2 REXX Batch file
|
1995-08-26
|
7KB
|
224 lines
/***************************************************************************/
/* B2Inst.Cmd */
/* */
/* Installs the "Belongs2" program in a hidden Startup folder. */
/* */
/* Revisions: */
/* 08/26/95 1.1 - Added zipname and changed FATname to "Belongs2". */
/* 03/12/94 1.0 - Added return codes for CID. */
/* 01/22/94 1.0 - Added code to hide subdirectory created for the */
/* Belongs2 executable file. */
/* 12/20/93 1.0 - Created. */
/***************************************************************************/
zipname = 'sample'
FATname = 'Belongs2'
exename = 'B e l o n g s 2'
targetdir = 'Belongs 2'
FATdir = 'BELONGS2'
/* Load REXX Utility Functions */
if AddRexxUtil( 'SysCreateObject' ) then signal ERROR
if AddRexxUtil( 'SysFileTree' ) then signal ERROR
if AddRexxUtil( 'SysSetObjectData' ) then signal ERROR
/* Get arguments */
parse upper arg targetdrive sourcepath extra
/* Verify target drive argument */
do forever
/* Make sure the target drive is a drive letter "d" or "d:" */
if LENGTH( targetdrive ) > 2 then
say 'Too many characters - enter a drive letter'
else if LENGTH( targetdrive ) > 0 then do
if DATATYPE( SUBSTR( targetdrive, 1, 1 ), 'Mixed case' ) = 0 then
say 'First character must be a drive letter'
else do
if LENGTH( targetdrive ) = 1 then do
targetdrive = targetdrive':'
leave
end /* Do */
else do
if SUBSTR( targetdrive, 2, 1 ) = ':' then
leave
else do
say 'Second character must be : or omitted'
end /* Do */
end /* Do */
end /* Do */
end /* Do */
/* Get the target drive */
say 'Enter drive where program executable is to be installed:'
pull targetdrive
end /* do */
/* Verify source path argument */
do forever
/* Default to current directory */
if sourcepath = '' then
sourcepath = '.'
/* See if executable file exists in given path */
filespec = sourcepath'\'zipname'.EXE'
fullpath = stream( filespec, 'c', 'query exists' )
if fullpath = '' then do
if sourcepath = '.' then
sourcepath = directory()
say 'File' zipname'.EXE not found in' sourcepath
end /* Do */
else
leave
/* Get the path */
say 'Enter path where installation files are located [.]:'
pull sourcepath
end /* do */
/* Suppress command display */
'@echo off'
/* See if directory already exists */
curdir = directory()
newdir = targetdrive'\'targetdir
if directory( newdir ) = newdir then do
say 'Directory "'targetdrive'\'targetdir'" (HPFS) already exists'
/* Change back to original directory */
call directory curdir
end /* Do */
else do
/* Create directory */
'md "'targetdrive'\'targetdir'"'
if rc = 0 then
say 'Directory "'targetdrive'\'targetdir'" (HPFS) created'
else do
/* Try FAT file system */
targetdir = FATdir
exename = FATname
newdir = targetdrive'\'targetdir
if directory( newdir ) = newdir then do
say 'Directory "'targetdrive'\'targetdir'" (FAT) already exists'
/* Change back to original directory */
call directory curdir
end /* Do */
else do
/* Create FAT directory */
'md "'targetdrive'\'targetdir'"'
if rc = 0 then
say 'Directory "'targetdrive'\'targetdir'" (FAT) created'
else do
say 'Unable to create directory on' targetdrive
signal ERROR
end /* Do */
end /* Do */
end /* Do */
end /* Do */
/* Hide the directory */
rc = SysFileTree( newdir, 'files', 'D', '*+***', '**+**' )
if rc then do
say 'SysFileTree command was not successful'
signal ERROR
end /* Do */
/* Make sure directory was found */
if files.0 = 0 then do
say 'Directory' newdir 'was not found'
say 'This should not occur, since the directory is being created'
signal ERROR
end /* Do */
/* Make sure the directory was hidden */
do i = 1 to files.0
if SUBSTR( files.i, 33, 1 ) = 'H' then
say 'Directory' SUBSTR( files.i, 38 ) 'has been hidden'
else do
say 'Directory' SUBSTR( files.i, 38 ) 'was not hidden'
end /* Do */
end /* do */
/* Copy the executable file to the directory */
'copy' fullpath '"'targetdrive'\'targetdir'\'exename'.EXE"' '/v'
if rc = 0 then
say 'Executable file copied to "'targetdrive'\'targetdir'"'
else do
say 'Unable to copy executable file to "'targetdrive'\'targetdir'"'
signal ERROR
end /* Do */
/* Create hidden Startup folder */
classname = 'WPStartup'
title = '.'
location = '<WP_NOWHERE>'
setup = 'OBJECTID=<HIDDEN_STARTUP>;'
result = SysCreateObject( classname, title, location, setup, 'f' )
if result = 1 /* created */ then
say 'Hidden startup folder created'
else do
/* See if object already exists */
result = SysSetObjectData( '<HIDDEN_STARTUP>', setup )
if result = 1 /* updated */ then
say 'Hidden startup folder already exists'
else do
say 'Unable to create hidden Startup folder'
signal ERROR
end /* Do */
end /* Do */
/* Create the program object */
classname = 'WPProgram'
title = '.'
location = '<HIDDEN_STARTUP>'
setup = 'OBJECTID=<BELONGS2_PROGRAM>;' || ,
'EXENAME='targetdrive'\'targetdir'\'exename'.EXE;' || ,
'PROGTYPE=PM;' || ,
'NODELETE=YES;NOMOVE=YES;NOTVISIBLE=YES;'
result = SysCreateObject( classname, title, location, setup, 'f' )
if result = 1 /* created */ then
say 'Program object created'
else do
/* See if object already exists */
result = SysSetObjectData( '<BELONGS2_PROGRAM>', setup )
if result = 1 /* updated */ then
say 'Program object already exists'
else do
say 'Unable to create program object'
signal ERROR
end /* Do */
end /* Do */
/* Exit the REXX procedure */
exit x2d(0000)
ERROR:
exit x2d(1604)
/* AddRexxUtil procedure */
AddRexxUtil: procedure
parse arg name
if RxFuncQuery( name ) \= 0 /* not registered */ then do
if RxFuncAdd( name, 'RexxUtil', name ) \= 0 /* not successful */ then do
say 'Unable to register REXX Utility Function' name
return 1 /* failure */
end /* Do */
end /* Do */
return 0 /* success */