home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / tlh120.zip / INSTALL / REMOVE.CMD < prev    next >
OS/2 REXX Batch file  |  1995-07-29  |  7KB  |  232 lines

  1. /*
  2.  *      REMOVE.CMD TLHIDE V1.2 - C.Langanke 1995
  3.  *
  4.  *      Syntax: REMOVE.CMD [/?]
  5.  *
  6.  *      Removes all WPS objects which where installed
  7.  *      through INSTALL.CMD of the TLHIDE package.
  8.  *
  9.  *      /?  -  display this help text
  10.  */
  11. /* The first comment is used as online help text */
  12.  
  13.  SIGNAL ON HALT
  14.  
  15.  TitleLine = STRIP(SUBSTR(SourceLine(2), 3));
  16.  PARSE VAR TitleLine CmdName'.CMD 'Info
  17.  Title     = CmdName Info
  18.  NewLine   = D2C(13)||D2C(10);
  19.  TRUE      = (1 = 1);
  20.  FALSE     = (0 = 1);
  21.   
  22.  /* some OS/2 Error codes */
  23.  ERROR.NO_ERROR         =  0;
  24.  ERROR.ACCESS_DENIED    =  5;
  25.  
  26.  /* determine directories */
  27.  InstallDir  = GetCallDir();
  28.  LastSlash   = LASTPOS( '\', InstallDir);
  29.  ProgDir     = LEFT(InstallDir, LastSlash - 1);
  30.  
  31.  /* default values */
  32.  MessageFile = ProgDir'\TLHIDE.MSG';
  33.  ExitMessage       = 'Interrupted by user.';
  34.  
  35. /*
  36.  *      load RexxUtil
  37.  */
  38.  
  39.  CALL RxFuncAdd    'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs';
  40.  CALL SysLoadFuncs;
  41.   
  42.  SAY;
  43.  SAY Title
  44.  SAY;
  45.  
  46. /*
  47.  *      show help
  48.  */
  49.  
  50.  ARG Parms
  51.  IF (POS('?', Parms) > 0) THEN
  52.  DO
  53.     rc = ShowHelp();
  54.     EXIT(ERROR.NO_ERROR)
  55.  END;
  56.  
  57.  
  58.  /* load MessageIds and YesNo Keys*/
  59.  MessageFileInfo        = LoadMsgString(0, MessageFile)
  60.  PARSE VAR MessageFileInfo InstMsgStart InstObjectsStart InstObjectsEnd YesKey NoKey ValidMenuKeys2 Language
  61.  
  62.  /* load MessageIds */
  63.  NlsMsg.AbortProgram     = LoadMsgString(InstMsgStart +  0, MessageFile);
  64.  NlsMsg.AlreadyActive    = LoadMsgString(InstMsgStart +  1, MessageFile);
  65.  NlsMsg.HaltMsg          = LoadMsgString(InstMsgStart +  2, MessageFile);
  66.  NlsMsg.Readme           = LoadMsgString(InstMsgStart +  3, MessageFile);
  67.  NlsMsg.Install          = LoadMsgString(InstMsgStart +  4, MessageFile);
  68.  NlsMsg.NLSSelect        = LoadMsgString(InstMsgStart +  5, MessageFile);
  69.  NlsMsg.LstSelect        = LoadMsgString(InstMsgStart +  6, MessageFile);
  70.  NlsMsg.Exit             = LoadMsgString(InstMsgStart +  7, MessageFile);
  71.  NlsMsg.Ok               = LoadMsgString(InstMsgStart +  8, MessageFile);
  72.  NlsMsg.Error            = LoadMsgString(InstMsgStart +  9, MessageFile);
  73.  NlsMsg.LstSelectPrompt  = LoadMsgString(InstMsgStart + 10, MessageFile);
  74.  NlsMsg.SelectDefault    = LoadMsgString(InstMsgStart + 11, MessageFile);
  75.  NlsMsg.InstallPrompt    = LoadMsgString(InstMsgStart + 12, MessageFile)
  76.  NlsMsg.TargetDirInstall = LoadMsgString(InstMsgStart + 13, MessageFile);
  77.  NlsMsg.TargetDirExists  = LoadMsgString(InstMsgStart + 14, MessageFile);
  78.  NlsMsg.InvalidParm      = LoadMsgString(InstMsgStart + 15, MessageFile);
  79.  NlsMsg.NotExist         = LoadMsgString(InstMsgStart + 16, MessageFile);
  80.  NlsMsg.XcopyFailed      = LoadMsgString(InstMsgStart + 17, MessageFile);
  81.  NlsMsg.DeactivatePrompt = LoadMsgString(InstMsgStart + 18, MessageFile);
  82.  NlsMsg.Deactivated      = LoadMsgString(InstMsgStart + 19, MessageFile);
  83.  NlsMsg.Create           = LoadMsgString(InstMsgStart + 20, MessageFile);
  84.  NlsMsg.Delete           = LoadMsgString(InstMsgStart + 21, MessageFile);
  85.  NlsMsg.MsgFileCopy      = LoadMsgString(InstMsgStart + 22, MessageFile);
  86.  NlsMsg.MsgFileLocked    = LoadMsgString(InstMsgStart + 23, MessageFile);
  87.  NlsMsg.InfFileCopy      = LoadMsgString(InstMsgStart + 24, MessageFile);
  88.  NlsMsg.InfFileLocked    = LoadMsgString(InstMsgStart + 25, MessageFile);
  89.  NlsMsg.Deinstall        = LoadMsgString(InstMsgStart + 26, MessageFile);
  90.  NlsMsg.NotInstalled     = LoadMsgString(InstMsgStart + 27, MessageFile);
  91.  
  92.  ExitMessage = NlsMsg.HaltMsg;
  93.  
  94. /*
  95.  *      ask to deinstall
  96.  */
  97.  
  98.  SAY;
  99.  IF (\ProceedWith(NlsMsg.Deinstall, YesKey, NoKey)) THEN
  100.     EXIT(ERROR.NO_ERROR);
  101.  
  102. /*
  103.  *      check, if folder object is installed
  104.  */
  105.  
  106.  /* read Details from Msg file */
  107.  ObjectDetails = LoadMsgString(InstObjectsStart, MessageFile);
  108.  
  109.  PARSE VAR ObjectDetails,
  110.         '"'ObjectClass'"',
  111.         '"'ObjectLocation'"',
  112.         '"'ObjectId'"',
  113.         '"'ObjectTitle'"',
  114.         '"'ObjectOption'"',
  115.         '"'ObjectExeName'"',
  116.         '"'ObjectParameters'"',
  117.         '"'ObjectSetup'"'
  118.  
  119.  /* test, if installed */
  120.  rc = SysSetObjectData(ObjectId, '');
  121.  IF (rc = 0) THEN
  122.  DO
  123.     SAY NlsMsg.NotInstalled
  124.     EXIT(ERROR.ACCESS_DENIED);
  125.  END;
  126.  
  127. /*
  128.  *      Now delete all objects
  129.  */
  130.  
  131.  DO i = InstObjectsEnd TO InstObjectsStart BY -1
  132.  
  133.     /* read Details from Msg file */
  134.     ObjectDetails = LoadMsgString(i, MessageFile);
  135.     PARSE VAR ObjectDetails,
  136.            '"'ObjectClass'"',
  137.            '"'ObjectLocation'"',
  138.            '"'ObjectId'"',
  139.            '"'ObjectTitle'"',
  140.            '"'ObjectOption'"',
  141.            '"'ObjectExeName'"',
  142.            '"'ObjectParameters'"',
  143.            '"'ObjectSetup'"'
  144.  
  145.     /* destroy object */
  146.     rc = DestroyObject(ObjectId, ObjectTitle);
  147.  END;
  148.  
  149.  
  150.  
  151.  EXIT(ERROR.NO_ERROR);
  152.  
  153. /* ------------------------------------------------------------------------- */
  154.  
  155. HALT:
  156.   SAY ExitMessage;
  157.   EXIT(ERROR.GEN_FAILURE);
  158.  
  159. /* ------------------------------------------------------------------------- */
  160. ShowHelp: PROCEDURE EXPOSE ExitMessage
  161.  
  162.  PARSE SOURCE . . ThisFile
  163.  
  164.  /* skip header */
  165.  DO i = 1 TO 3
  166.     rc = LINEIN(ThisFile);
  167.  END;
  168.  
  169.  /* show help */
  170.  DO WHILE (ThisLine \= ' */')
  171.     ThisLine = LINEIN(Thisfile);
  172.     SAY SUBSTR(ThisLine, 7);
  173.  END;
  174.  
  175.  /* close file */
  176.  rc = LINEOUT(Thisfile);
  177.  
  178.  RETURN('');
  179.  
  180. /* ------------------------------------------------------------------------- */
  181. DestroyObject: PROCEDURE EXPOSE NlsMsg. ExitMessage
  182.  PARSE ARG ObjectId, ObjectTitle
  183.  
  184.  CALL CHAROUT, LEFT(ObjectTitle, 50) NlsMsg.Delete '... ';
  185.  
  186.  rc = SysDestroyObject(ObjectId);
  187.  
  188.  IF (rc) THEN
  189.     SAY NlsMsg.Ok
  190.  ELSE
  191.     SAY NlsMsg.Error '!'
  192.  
  193.  RETURN(rc);
  194.    
  195. /* ------------------------------------------------------------------------- */
  196. LoadMsgString: PROCEDURE EXPOSE ExitMessage
  197.  ARG MsgId, MessageFile
  198.  
  199.  Message = SysGetMessage(MsgId, MessageFile);
  200.  RETURN(LEFT(Message, LENGTH(Message) - 2));
  201.  
  202. /* ------------------------------------------------------------------------- */
  203. GetCalldir: PROCEDURE EXPOSE ExitMessage 
  204. PARSE SOURCE . . CallName
  205.  CallDir = FILESPEC('Drive', CallName)||FILESPEC('Path', CallName);
  206.  RETURN(LEFT(CallDir, LENGTH(CallDir) - 1));
  207.  
  208. /* ------------------------------------------------------------------------- */
  209. ProceedWith: PROCEDURE EXPOSE ExitMessage 
  210.  PARSE ARG Prompt, Yes, No
  211.  
  212.  IF (No = '') THEN
  213.  DO
  214.     ResponseKeys  = 'J N A W I'; /* SysGetMessage(0); */
  215.     Yes           = WORD(ResponseKeys, 1);
  216.     No            = WORD(ResponseKeys, 2);
  217.     ch            = ' ';
  218.  END;
  219.  ValidResponse = Yes||No;
  220.  
  221.  SAY;
  222.  CALL CHAROUT ,Prompt '('Yes'/'No') '
  223.  DO WHILE (POS(ch, ValidResponse) = 0)
  224.     ch = SysGetKey('NOECHO');
  225.     ch = TRANSLATE(ch);
  226.     IF (POS(ch, ValidResponse) = 0) THEN BEEP(800, 200);
  227.  END;
  228.  SAY;
  229.  SAY;
  230.  RETURN(ch = Yes);
  231.  
  232.