home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xwplascr.zip / XWPL0208.ZIP / release / install.cmd < prev    next >
OS/2 REXX Batch file  |  2001-12-16  |  15KB  |  416 lines

  1. /* XWorkplace installation script
  2.    (C) 1998-2000 Ulrich Möller
  3.  
  4.    NOTE: THIS SCRIPT IS OUTDATED AND SHOULD NOT BE USED.
  5.  
  6.    This is just an updated version of the XFolder
  7.    install script. XWorkplace now uses WarpIN to install.
  8.    This file is actually obsolete and only retained in
  9.    case somebody wants to do some testing.
  10.  
  11.    Optional parameters: three-digit language code
  12.    to start installation with a certain language
  13.    without being prompted.
  14.  
  15.    This script is language-independent. It relies on
  16.    the files in the ./INSTALL subdirectory which should
  17.    contain the necessary language-dependent strings. */
  18.  
  19. '@echo off'
  20. signal on halt; trace off
  21.  
  22. call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  23. call SysLoadFuncs
  24.  
  25. /* get the directory from where we're started */
  26. parse source mydir;
  27. parse var mydir x1 x2 mydir;
  28. mydir = filespec("D", mydir)||filespec("P", mydir);
  29. if (right(mydir, 1) = "\") then
  30.     mydir = left(mydir, length(mydir)-1);
  31.  
  32. nl = '0a0d'x;
  33. IniKey = "XFolder";
  34. XFolderVersion = "0.9.0";
  35.  
  36. foundList.0 = 0
  37.  
  38. Say "XWorkplace "XFolderVersion" installation"
  39.  
  40. Say ""
  41. Say "WARNING!!!"
  42. Say "This script (install.cmd) was used only by old XFolder versions"
  43. Say "(before XWorkplace V0.9.1) to install XFolder. XWorkplace now"
  44. Say "uses WarpIN for installation and de-installation. Using this"
  45. Say "script is NOT RECOMMENDED and can easily mess up your system,"
  46. Say "since this script has not been tested for a long time."
  47. Say "Are you sure you want to continue? (Y/N)"
  48. do until (pos(key,"YN") > 0)
  49.    key = translate(SysGetKey("NOECHO"))
  50. end /* do */
  51.  
  52. if (key == "N") then exit
  53.  
  54. /* parse parameters: */
  55. parse arg args
  56.  
  57. LanguageCodeValid = 0;
  58.  
  59. if (args \= "") then
  60.     LanguageCode = args;
  61. else do
  62.     /* no parameters given: search ./INSTALL for language files
  63.        and display them */
  64.     do
  65.         MsgFiles.0 = 0;
  66.         Say ""
  67.         rc = SysFileTree(mydir"\install\*.msg", "MsgFiles", "FO");
  68.         if (msgFiles.0 = 0) then do
  69.             /* none found: error */
  70.             Say ""
  71.             Say "The XWorkplace install program was unable to find any of its language"
  72.             Say "files. This can have the following reasons:"
  73.             Say "1) You have not downloaded any National Language Support (NLS) files."
  74.             Say "   Starting with V0.83, NLS is no longer included in the base package,"
  75.             Say "   so you must download at least one XWorkplace NLS package."
  76.             Say "   See the README.1ST file for details."
  77.             Say "2) The ZIP files you downloaded have been damaged."
  78.             Say "3) You did not unzip the files properly. There must be a several"
  79.             Say "   subdirectories under the directory where INSTALL.CMD resides."
  80.             Say "   Place all the zip files in the same directory."
  81.             Say "   With InfoZIP, use:           unzip <file>.zip"
  82.             Say "   With PkZIP, use:             pkzip /extract /directories <file>.zip"
  83.             "pause > nul"
  84.             exit
  85.         end
  86.         else if (MsgFiles.0 = 1) then do
  87.             /* only one set of language files: don't ask */
  88.             fname = filespec("NAME", MsgFiles.1);
  89.             LanguageCode = substr(fname, 5, 3)
  90.             signal begin
  91.         end
  92.         else do while (LanguageCodeValid = 0)
  93.             do i = 1 to MsgFiles.0
  94.                 /* for each language found, display the welcome
  95.                    string from the msg file ("Enter 001 to install in English...") */
  96.                 fname = filespec("NAME", MsgFiles.i);
  97.                 "call bin\xhelp -F install\"fname" IdentifyMsg"
  98.             end
  99.  
  100.             /* have the user enter the language code */
  101.             Say ""
  102.             call charout , ">>"
  103.             parse pull LanguageCode
  104.  
  105.             if (stream("install\inst"LanguageCode".msg", "c", "QUERY EXISTS") = "") then do
  106.                 say "This is not a valid language code.";
  107.             end
  108.             else
  109.                 /* exit loop */
  110.                 LanguageCodeValid = 1;
  111.         end
  112.     end;
  113. end;
  114.  
  115. /* now let's go */
  116. begin:
  117. /* this is a shortcut for displaying language-dependent stuff */
  118. callxhelpStr = "call bin\xhelp -F install\inst"LanguageCode".msg"
  119.  
  120. cls
  121.  
  122. Say "XWorkplace "XFolderVersion" installation"
  123.  
  124. callxhelpStr "welcomeMsg"
  125. call pause
  126.  
  127. callxhelpStr "licenceMsg"
  128. call pause
  129.  
  130. loop:
  131. /* ask for what we should do: register, deregister etc. */
  132. callxhelpStr "queryActionMsg"
  133. key = ''
  134. do until (pos(key,"RDX") > 0)
  135.    key = translate(SysGetKey("NOECHO"))
  136. end /* do */
  137. Say key
  138.  
  139. select
  140.     when (key = "R") then do
  141.  
  142.         /* REGISTER */
  143.  
  144.         /* delete all INI keys of previous XFolder versions
  145.            because the XFolder INI data changes with every
  146.            release */
  147.         rc = SysINI('USER', "XFolder_0_40", "DELETE:");
  148.         rc = SysINI('USER', "XFolder_0_41", "DELETE:");
  149.         rc = SysINI('USER', "XFolder_0_42", "DELETE:");
  150.         rc = SysINI('USER', "XFolder 0.5x", "DELETE:");
  151.         rc = SysINI('USER', "XFolder07", "DELETE:");
  152.         rc = SysINI('USER', "XFolder7", "DELETE:");
  153.  
  154.         /* set INI data for this version */
  155.         rc = SysINI('USER', IniKey, "XFolderPath", mydir||'0'x);
  156.         rc = SysINI('USER', IniKey, "Language", LanguageCode||'0'x);
  157.         rc = SysINI('USER', IniKey, "JustInstalled", '1'||'0'x);
  158.         rc = SysINI('USER', IniKey, "Version", XFolderVersion||'0'x);
  159.  
  160.         /* remove WPS classes that might already be registered */
  161.         callxhelpStr "unregisteringOldMsg";
  162.         call pause
  163.  
  164.         say "";
  165.         call charout , "Deregistering XWPClassList: "
  166.         if (SysDeregisterObjectClass("XWPClassList")) then
  167.             Say "OK";
  168.             else Say "not found";
  169.         call charout , "Deregistering XWPTrashCan: "
  170.         if (SysDeregisterObjectClass("XWPTrashCan")) then
  171.             Say "OK";
  172.             else Say "not found";
  173.         call charout , "Deregistering XWPTrashObject: "
  174.         if (SysDeregisterObjectClass("XWPTrashObject")) then
  175.             Say "OK";
  176.             else Say "not found";
  177.         call charout , "Deregistering XWPSetup: "
  178.         if (SysDeregisterObjectClass("XWPSetup")) then
  179.             Say "OK";
  180.             else Say "not found";
  181.         call charout , "Deregistering XFldWPS: "
  182.         if (SysDeregisterObjectClass("XFldWPS")) then
  183.             Say "OK";
  184.             else Say "not found";
  185.         call charout , "Deregistering XFldStartup: "
  186.         if (SysDeregisterObjectClass("XFldStartup")) then
  187.             Say "OK";
  188.             else Say "not found";
  189.         call charout , "Deregistering XFldShutdown: "
  190.         if (SysDeregisterObjectClass("XFldShutdown")) then
  191.             Say "OK";
  192.             else Say "not found";
  193.         "bin\repclass.exe WPSystem XFldSystem"
  194.         "bin\repclass.exe WPProgram XFldProgram"
  195.         "bin\repclass.exe WPDisk XFldDisk"
  196.         "bin\repclass.exe WPDataFile XFldDataFile"
  197.         "bin\repclass.exe WPDesktop XFldDesktop"
  198.         "bin\repclass.exe WPFolder XFolder"
  199.         "bin\repclass.exe WPFileSystem XFldFileSystem"
  200.         "bin\repclass.exe WPObject XFldObject"
  201.         "bin\repclass.exe WPProgramFile XWPProgramFile"
  202.         "bin\repclass.exe WPSound XWPSound"
  203.         "bin\repclass.exe WPMouse XWPMouse"
  204.         "bin\repclass.exe WPKeyboard XWPKeyboard"
  205.  
  206.         /* install classes for this version */
  207.         say "";
  208.         callxhelpStr "registeringNewMsg";
  209.         call pause
  210.  
  211.         say "";
  212.         "bin\repclass.exe WPFolder XFolder" mydir||"\bin\xfldr.dll";
  213.         "bin\repclass.exe WPObject XFldObject" mydir||"\bin\xfldr.dll";
  214.         /* "bin\repclass.exe WPFileSystem XFldFileSystem" mydir||"\bin\xfldr.dll"; */
  215.         "bin\repclass.exe WPDataFile XFldDataFile" mydir||"\bin\xfldr.dll";
  216.         "bin\repclass.exe WPDisk XFldDisk" mydir||"\bin\xfldr.dll";
  217.         "bin\repclass.exe WPDesktop XFldDesktop" mydir||"\bin\xfldr.dll";
  218.         "bin\repclass.exe WPProgramFile XWPProgramFile" mydir||"\bin\xfldr.dll";
  219.         "bin\repclass.exe WPSound XWPSound" mydir||"\bin\xfldr.dll";
  220.         "bin\repclass.exe WPMouse XWPMouse" mydir||"\bin\xfldr.dll";
  221.         "bin\repclass.exe WPKeyboard XWPKeyboard" mydir||"\bin\xfldr.dll";
  222.         say "";
  223.         call charout , "Registering XFldSystem: "
  224.         if (SysRegisterObjectClass("XFldSystem", mydir||"\bin\xfldr.dll")) then
  225.             Say "OK";
  226.             else Say "failed";
  227.         call charout , "Registering XFldWPS: "
  228.         if (SysRegisterObjectClass("XFldWPS", mydir||"\bin\xfldr.dll")) then
  229.             Say "OK";
  230.             else Say "failed";
  231.         call charout , "Registering XFldStartup: "
  232.         if (SysRegisterObjectClass("XFldStartup", mydir||"\bin\xfldr.dll")) then
  233.             Say "OK";
  234.             else Say "failed";
  235.         call charout , "Registering XFldShutdown: "
  236.         if (SysRegisterObjectClass("XFldShutdown", mydir||"\bin\xfldr.dll")) then
  237.             Say "OK";
  238.             else Say "failed";
  239.         call charout , "Registering XWPSetup: "
  240.         if (SysRegisterObjectClass("XWPSetup", mydir||"\bin\xfldr.dll")) then
  241.             Say "OK";
  242.             else Say "failed";
  243.         call charout , "Registering XWPTrashCan: "
  244.         if (SysRegisterObjectClass("XWPTrashCan", mydir||"\bin\xfldr.dll")) then
  245.             Say "OK";
  246.             else Say "failed";
  247.         call charout , "Registering XWPTrashObject: "
  248.         if (SysRegisterObjectClass("XWPTrashObject", mydir||"\bin\xfldr.dll")) then
  249.             Say "OK";
  250.             else Say "failed";
  251.         call charout , "Registering XWPClassList: "
  252.         if (SysRegisterObjectClass("XWPClassList", mydir||"\bin\xfldr.dll")) then
  253.             Say "OK";
  254.             else Say "failed";
  255.  
  256.         /* check for Object Desktop TSEnhFolder */
  257.         ClassList.0 = 0;
  258.         call SysQueryClassList "ClassList.";
  259.         if (ClassList.0 > 0) then
  260.             do i = 1 to ClassList.0
  261.                 parse var ClassList.i Class DLL
  262.                 if (Class = "TSEnhFolder") then do
  263.                     callxhelpStr "QueryODMsg";
  264.                     key = ''
  265.                     do until (pos(key,"YN") > 0)
  266.                        key = translate(SysGetKey("NOECHO"))
  267.                     end;
  268.                     say key;
  269.                     say "";
  270.                     if (key = "Y") then do
  271.                         /* remove TSEnhFolder and undo replacement */
  272.                         "bin\repclass.exe WPFolder TSEnhFolder"
  273.                         /* and register and replace again;
  274.                            OBJDEFLD.DLL should be on the LIBPATH */
  275.                         "bin\repclass.exe WPFolder TSEnhFolder OBJDEFLD"
  276.                         callxhelpStr "ODDeregdMsg";
  277.                         "pause >NUL"
  278.                     end;
  279.                 end;
  280.             end
  281.  
  282.         /* restart WPS? */
  283.         callxhelpStr "shutdownMsg";
  284.         key = ''
  285.         do until (pos(key,"YN") > 0)
  286.            key = translate(SysGetKey("NOECHO"))
  287.         end /* do */
  288.         Say key
  289.         if (key = "Y") then
  290.             "bin\wpsreset -D"
  291.         else do
  292.             callxhelpStr "howtoMsg";
  293.             "pause >NUL"
  294.         end
  295.         exit
  296.     end
  297.  
  298.     when (key = "D") then do
  299.         /* UNREGISTER */
  300.  
  301.         callxhelpStr "unregisteringOldMsg";
  302.  
  303.         say "";
  304.         call charout , "Deregistering XWPClassList: "
  305.         if (SysDeregisterObjectClass("XWPClassList")) then
  306.             Say "OK";
  307.             else Say "not found";
  308.         call charout , "Deregistering XWPTrashCan: "
  309.         if (SysDeregisterObjectClass("XWPTrashCan")) then
  310.             Say "OK";
  311.             else Say "not found";
  312.         call charout , "Deregistering XWPTrashObject: "
  313.         if (SysDeregisterObjectClass("XWPTrashObject")) then
  314.             Say "OK";
  315.             else Say "not found";
  316.         call charout , "Deregistering XWPSetup: "
  317.         if (SysDeregisterObjectClass("XWPSetup")) then
  318.             Say "OK";
  319.             else Say "not found";
  320.         call charout , "Deregistering XFldWPS: "
  321.         if (SysDeregisterObjectClass("XFldWPS")) then
  322.             Say "OK";
  323.             else Say "not found";
  324.         call charout , "Deregistering XFldStartup: "
  325.         if (SysDeregisterObjectClass("XFldStartup")) then
  326.             Say "OK";
  327.             else Say "not found";
  328.         call charout , "Deregistering XFldShutdown: "
  329.         if (SysDeregisterObjectClass("XFldShutdown")) then
  330.             Say "OK";
  331.             else Say "not found";
  332.         "bin\repclass.exe WPSystem XFldSystem"
  333.         "bin\repclass.exe WPProgram XFldProgram"
  334.         "bin\repclass.exe WPDisk XFldDisk"
  335.         "bin\repclass.exe WPDataFile XFldDataFile"
  336.         "bin\repclass.exe WPDesktop XFldDesktop"
  337.         "bin\repclass.exe WPFolder XFolder"
  338.         "bin\repclass.exe WPFileSystem XFldFileSystem"
  339.         "bin\repclass.exe WPObject XFldObject"
  340.         "bin\repclass.exe WPProgramFile XWPProgramFile"
  341.         "bin\repclass.exe WPSound XWPSound"
  342.         "bin\repclass.exe WPMouse XWPMouse"
  343.         "bin\repclass.exe WPKeyboard XWPKeyboard"
  344.  
  345.         /* clean up INIs too? */
  346.         say "";
  347.         callxhelpStr "removeIniMsg";
  348.         key = ''
  349.         do until (pos(key,"YN") > 0)
  350.            key = translate(SysGetKey("NOECHO"))
  351.         end /* do */
  352.         Say key
  353.         if (key = "Y") then do
  354.             /* XFolder keys in OS2.INI */
  355.             rc = SysINI('USER', IniKey, "DELETE:");
  356.             /* XFolder sounds in MMPM.INI */
  357.             MMINI = GetBootDrive()||"\MMOS2\MMPM.INI";
  358.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "555", "DELETE:");
  359.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "556", "DELETE:");
  360.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "558", "DELETE:");
  361.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "559", "DELETE:");
  362.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "560", "DELETE:");
  363.         end;
  364.  
  365.         /* restart WPS? */
  366.         say "";
  367.         callxhelpStr "shutdownMsg";
  368.         key = ''
  369.         do until (pos(key,"YN") > 0)
  370.            key = translate(SysGetKey("NOECHO"))
  371.         end /* do */
  372.         Say key
  373.         if (key = "Y") then
  374.             "bin\wpsreset -D"
  375.         exit
  376.     end;
  377.  
  378.     when (key = "X") then
  379.         exit;
  380. end /* select */
  381.  
  382. /* wrong key pressed: keep looping */
  383. say ""
  384. signal loop;
  385.  
  386. halt:
  387. say '0d0a'x'Installation aborted!'
  388. exit
  389.  
  390. createObjects:
  391.         callxhelpStr "creatingObjMsg"
  392.         "call install\crobj"LanguageCode".cmd"
  393. return;
  394.  
  395. GetBootDrive: procedure
  396.     parse upper value VALUE( "PATH",, "OS2ENVIRONMENT" ) with "\OS2\SYSTEM" -2 boot_drive +2
  397. return boot_drive
  398.  
  399. pause:  procedure
  400. key = ""
  401. do while (key = "")
  402.    key = SysGetKey("NOECHO")
  403. end /* do */
  404. say ""
  405. return
  406.  
  407. strReplace: procedure
  408.     /* syntax: result = strReplace(str, old, new) */
  409.     /* will replace a with b in oldstr */
  410.     parse arg str, old, new
  411.     p = pos(old, str)
  412.     if (p > 0) then
  413.         str = left(str, p-1)||new||substr(str,p+length(old))
  414. return str
  415.  
  416.