home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
om9701.zip
/
os2minst.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-09-07
|
7KB
|
205 lines
/***************************************************************************/
/* OS2MInst.Cmd */
/* */
/* Installs the "OS/2 Magazine Article Database" */
/* */
/* Revisions: */
/* 09/07/94 1.0 - Created. */
/***************************************************************************/
objectid = '<MA9409>'
FATname = 'OS2MAGS'
INFname = 'OS!2 Magazine Article Database'
targetdir = 'OS!2 Mags'
FATdir = 'OS!2MAGS'
/* 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 location 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 OS/2 Magazine Article Database is to be installed:'
pull targetdrive
end /* do */
/* Verify source path argument */
do forever
/* Default to current directory */
if sourcepath = '' then
sourcepath = '.'
/* See if the .INF file exists in the given path */
filespec = sourcepath'\'FATname'.INF'
fullpath = stream( filespec, 'c', 'query exists' )
if fullpath = '' then do
if sourcepath = '.' then
sourcepath = directory()
say 'File' FATname'.INF not found in' sourcepath
end /* Do */
else
leave
/* Get the path */
say 'Enter path where installation files are located [.]:'
pull sourcepath
end /* do */
/* See if the .INF file exists in the given path */
filespec = sourcepath'\'FATname'.ICO'
iconfull = stream( filespec, 'c', 'query exists' )
if iconfull = '' then do
if sourcepath = '.' then
sourcepath = directory()
say 'File' FATname'.ICO not found in' sourcepath
end /* Do */
/* If no location specified, put it on the desktop */
if location = '' then
location = '<WP_DESKTOP>'
/* 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
INFname = 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 */
/* Check 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 */
/* Copy the .INF file to the specified directory */
'copy' fullpath '"'targetdrive'\'targetdir'\'INFname'.Inf"' '/v'
if rc = 0 then
say INFname'.Inf copied to "'targetdrive'\'targetdir'"'
else do
say 'Unable to copy' INFname'.Inf to "'targetdrive'\'targetdir'"'
signal ERROR
end /* Do */
/* Create the program object */
classname = 'WPProgram'
title = 'OS/2 Magazine^Article Database'
setup = 'OBJECTID='objectid';' || ,
'EXENAME=VIEW.EXE;' || ,
'PARAMETERS="'targetdrive'\'targetdir'\'INFname'" ABOUT;' || ,
'ICONFILE='iconfull';' || ,
'PROGTYPE=PM;'
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( objectid, 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 */