home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
tlh120.zip
/
INSTALL
/
REMOVE.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-07-29
|
7KB
|
232 lines
/*
* REMOVE.CMD TLHIDE V1.2 - C.Langanke 1995
*
* Syntax: REMOVE.CMD [/?]
*
* Removes all WPS objects which where installed
* through INSTALL.CMD of the TLHIDE package.
*
* /? - display this help text
*/
/* The first comment is used as online help text */
SIGNAL ON HALT
TitleLine = STRIP(SUBSTR(SourceLine(2), 3));
PARSE VAR TitleLine CmdName'.CMD 'Info
Title = CmdName Info
NewLine = D2C(13)||D2C(10);
TRUE = (1 = 1);
FALSE = (0 = 1);
/* some OS/2 Error codes */
ERROR.NO_ERROR = 0;
ERROR.ACCESS_DENIED = 5;
/* determine directories */
InstallDir = GetCallDir();
LastSlash = LASTPOS( '\', InstallDir);
ProgDir = LEFT(InstallDir, LastSlash - 1);
/* default values */
MessageFile = ProgDir'\TLHIDE.MSG';
ExitMessage = 'Interrupted by user.';
/*
* load RexxUtil
*/
CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs';
CALL SysLoadFuncs;
SAY;
SAY Title
SAY;
/*
* show help
*/
ARG Parms
IF (POS('?', Parms) > 0) THEN
DO
rc = ShowHelp();
EXIT(ERROR.NO_ERROR)
END;
/* load MessageIds and YesNo Keys*/
MessageFileInfo = LoadMsgString(0, MessageFile)
PARSE VAR MessageFileInfo InstMsgStart InstObjectsStart InstObjectsEnd YesKey NoKey ValidMenuKeys2 Language
/* load MessageIds */
NlsMsg.AbortProgram = LoadMsgString(InstMsgStart + 0, MessageFile);
NlsMsg.AlreadyActive = LoadMsgString(InstMsgStart + 1, MessageFile);
NlsMsg.HaltMsg = LoadMsgString(InstMsgStart + 2, MessageFile);
NlsMsg.Readme = LoadMsgString(InstMsgStart + 3, MessageFile);
NlsMsg.Install = LoadMsgString(InstMsgStart + 4, MessageFile);
NlsMsg.NLSSelect = LoadMsgString(InstMsgStart + 5, MessageFile);
NlsMsg.LstSelect = LoadMsgString(InstMsgStart + 6, MessageFile);
NlsMsg.Exit = LoadMsgString(InstMsgStart + 7, MessageFile);
NlsMsg.Ok = LoadMsgString(InstMsgStart + 8, MessageFile);
NlsMsg.Error = LoadMsgString(InstMsgStart + 9, MessageFile);
NlsMsg.LstSelectPrompt = LoadMsgString(InstMsgStart + 10, MessageFile);
NlsMsg.SelectDefault = LoadMsgString(InstMsgStart + 11, MessageFile);
NlsMsg.InstallPrompt = LoadMsgString(InstMsgStart + 12, MessageFile)
NlsMsg.TargetDirInstall = LoadMsgString(InstMsgStart + 13, MessageFile);
NlsMsg.TargetDirExists = LoadMsgString(InstMsgStart + 14, MessageFile);
NlsMsg.InvalidParm = LoadMsgString(InstMsgStart + 15, MessageFile);
NlsMsg.NotExist = LoadMsgString(InstMsgStart + 16, MessageFile);
NlsMsg.XcopyFailed = LoadMsgString(InstMsgStart + 17, MessageFile);
NlsMsg.DeactivatePrompt = LoadMsgString(InstMsgStart + 18, MessageFile);
NlsMsg.Deactivated = LoadMsgString(InstMsgStart + 19, MessageFile);
NlsMsg.Create = LoadMsgString(InstMsgStart + 20, MessageFile);
NlsMsg.Delete = LoadMsgString(InstMsgStart + 21, MessageFile);
NlsMsg.MsgFileCopy = LoadMsgString(InstMsgStart + 22, MessageFile);
NlsMsg.MsgFileLocked = LoadMsgString(InstMsgStart + 23, MessageFile);
NlsMsg.InfFileCopy = LoadMsgString(InstMsgStart + 24, MessageFile);
NlsMsg.InfFileLocked = LoadMsgString(InstMsgStart + 25, MessageFile);
NlsMsg.Deinstall = LoadMsgString(InstMsgStart + 26, MessageFile);
NlsMsg.NotInstalled = LoadMsgString(InstMsgStart + 27, MessageFile);
ExitMessage = NlsMsg.HaltMsg;
/*
* ask to deinstall
*/
SAY;
IF (\ProceedWith(NlsMsg.Deinstall, YesKey, NoKey)) THEN
EXIT(ERROR.NO_ERROR);
/*
* check, if folder object is installed
*/
/* read Details from Msg file */
ObjectDetails = LoadMsgString(InstObjectsStart, MessageFile);
PARSE VAR ObjectDetails,
'"'ObjectClass'"',
'"'ObjectLocation'"',
'"'ObjectId'"',
'"'ObjectTitle'"',
'"'ObjectOption'"',
'"'ObjectExeName'"',
'"'ObjectParameters'"',
'"'ObjectSetup'"'
/* test, if installed */
rc = SysSetObjectData(ObjectId, '');
IF (rc = 0) THEN
DO
SAY NlsMsg.NotInstalled
EXIT(ERROR.ACCESS_DENIED);
END;
/*
* Now delete all objects
*/
DO i = InstObjectsEnd TO InstObjectsStart BY -1
/* read Details from Msg file */
ObjectDetails = LoadMsgString(i, MessageFile);
PARSE VAR ObjectDetails,
'"'ObjectClass'"',
'"'ObjectLocation'"',
'"'ObjectId'"',
'"'ObjectTitle'"',
'"'ObjectOption'"',
'"'ObjectExeName'"',
'"'ObjectParameters'"',
'"'ObjectSetup'"'
/* destroy object */
rc = DestroyObject(ObjectId, ObjectTitle);
END;
EXIT(ERROR.NO_ERROR);
/* ------------------------------------------------------------------------- */
HALT:
SAY ExitMessage;
EXIT(ERROR.GEN_FAILURE);
/* ------------------------------------------------------------------------- */
ShowHelp: PROCEDURE EXPOSE ExitMessage
PARSE SOURCE . . ThisFile
/* skip header */
DO i = 1 TO 3
rc = LINEIN(ThisFile);
END;
/* show help */
DO WHILE (ThisLine \= ' */')
ThisLine = LINEIN(Thisfile);
SAY SUBSTR(ThisLine, 7);
END;
/* close file */
rc = LINEOUT(Thisfile);
RETURN('');
/* ------------------------------------------------------------------------- */
DestroyObject: PROCEDURE EXPOSE NlsMsg. ExitMessage
PARSE ARG ObjectId, ObjectTitle
CALL CHAROUT, LEFT(ObjectTitle, 50) NlsMsg.Delete '... ';
rc = SysDestroyObject(ObjectId);
IF (rc) THEN
SAY NlsMsg.Ok
ELSE
SAY NlsMsg.Error '!'
RETURN(rc);
/* ------------------------------------------------------------------------- */
LoadMsgString: PROCEDURE EXPOSE ExitMessage
ARG MsgId, MessageFile
Message = SysGetMessage(MsgId, MessageFile);
RETURN(LEFT(Message, LENGTH(Message) - 2));
/* ------------------------------------------------------------------------- */
GetCalldir: PROCEDURE EXPOSE ExitMessage
PARSE SOURCE . . CallName
CallDir = FILESPEC('Drive', CallName)||FILESPEC('Path', CallName);
RETURN(LEFT(CallDir, LENGTH(CallDir) - 1));
/* ------------------------------------------------------------------------- */
ProceedWith: PROCEDURE EXPOSE ExitMessage
PARSE ARG Prompt, Yes, No
IF (No = '') THEN
DO
ResponseKeys = 'J N A W I'; /* SysGetMessage(0); */
Yes = WORD(ResponseKeys, 1);
No = WORD(ResponseKeys, 2);
ch = ' ';
END;
ValidResponse = Yes||No;
SAY;
CALL CHAROUT ,Prompt '('Yes'/'No') '
DO WHILE (POS(ch, ValidResponse) = 0)
ch = SysGetKey('NOECHO');
ch = TRANSLATE(ch);
IF (POS(ch, ValidResponse) = 0) THEN BEEP(800, 200);
END;
SAY;
SAY;
RETURN(ch = Yes);