home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 February / PCO_0299.ISO / filesbbs / os2 / xfolder.arj / XFLD082.ZIP / install.cmd < prev    next >
Encoding:
Text File  |  1998-11-19  |  10.9 KB  |  328 lines

  1. /* XFolder installation program
  2.    (w) (c) 1998 Ulrich Möller */
  3.  
  4. /* Optional parameters: three-digit language code
  5.    to start installation with a certain language
  6.    without being prompted. */
  7.  
  8. /* This script is language-independent. It relies on
  9.    the files in the ./INSTALL subdirectory which should
  10.    contain the necessary language-dependent strings. */
  11.  
  12. '@echo off'
  13. signal on halt; trace off
  14.  
  15. call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  16. call SysLoadFuncs
  17.  
  18. /* get the directory from where we're started */
  19. parse source mydir;
  20. parse var mydir x1 x2 mydir;
  21. mydir = filespec("D", mydir)||filespec("P", mydir);
  22. if (right(mydir, 1) = "\") then
  23.     mydir = left(mydir, length(mydir)-1);
  24.  
  25. nl = '0a0d'x;
  26. IniKey = "XFolder";
  27. XFolderVersion = "0.82 beta";
  28.  
  29. foundList.0 = 0
  30.  
  31. Say "XFolder "XFolderVersion" installation"
  32.  
  33. /* parse parameters: */
  34. parse arg args
  35.  
  36. LanguageCodeValid = 0;
  37.  
  38. if (args \= "") then
  39.     LanguageCode = args;
  40. else do
  41.     /* no parameters given: search ./INSTALL for language files
  42.        and display them */
  43.     do
  44.         MsgFiles.0 = 0;
  45.         Say ""
  46.         rc = SysFileTree(mydir"\install\*.msg", "MsgFiles", "FO");
  47.         if (msgFiles.0 = 0) then do
  48.             /* none found: error */
  49.             Say ""
  50.             Say "The XFolder install program was unable to find any of its language"
  51.             Say "files. Either the ZIP file you downloaded has been damaged or you"
  52.             Say "did not unzip it properly. There must be a several subdirectories"
  53.             Say "under the directory where the INSTALL.CMD script resides."
  54.             Say "With InfoZIP, use:           unzip xfldr.zip"
  55.             Say "With PkZIP, use:             pkzip /extract /directories xfldr.zip"
  56.             "pause > nul"
  57.             exit
  58.         end
  59.         else if (MsgFiles.0 = 1) then do
  60.             /* only one set of language files: don't ask */
  61.             fname = filespec("NAME", MsgFiles.1);
  62.             LanguageCode = substr(fname, 5, 3)
  63.             signal begin
  64.         end
  65.         else do while (LanguageCodeValid = 0)
  66.             do i = 1 to MsgFiles.0
  67.                 /* for each language found, display the welcome
  68.                    string from the msg file ("Enter 001 to install in English...") */
  69.                 fname = filespec("NAME", MsgFiles.i);
  70.                 "call bin\xhelp -F install\"fname" IdentifyMsg"
  71.             end
  72.  
  73.             /* have the user enter the language code */
  74.             Say ""
  75.             call charout , ">>"
  76.             parse pull LanguageCode
  77.  
  78.             if (stream("install\inst"LanguageCode".msg", "c", "QUERY EXISTS") = "") then do
  79.                 say "This is not a valid language code.";
  80.             end
  81.             else
  82.                 /* exit loop */
  83.                 LanguageCodeValid = 1;
  84.         end
  85.     end;
  86. end;
  87.  
  88. /* now let's go */
  89. begin:
  90. /* this is a shortcut for displaying language-dependent stuff */
  91. callxhelpStr = "call bin\xhelp -F install\inst"LanguageCode".msg"
  92.  
  93. cls
  94.  
  95. Say "XFolder "XFolderVersion" installation"
  96.  
  97. callxhelpStr "welcomeMsg"
  98. call pause
  99.  
  100. callxhelpStr "licenceMsg"
  101. call pause
  102.  
  103. loop:
  104. /* ask for what we should do: register, deregister etc. */
  105. callxhelpStr "queryActionMsg"
  106. key = ''
  107. do until (pos(key,"RDX") > 0)
  108.    key = translate(SysGetKey("NOECHO"))
  109. end /* do */
  110. Say key
  111.  
  112. select
  113.     when (key = "R") then do
  114.  
  115.         /* REGISTER */
  116.  
  117.         /* delete all INI keys of previous XFolder versions
  118.            because the XFolder INI data changes with every
  119.            release */
  120.         rc = SysINI('USER', "XFolder_0_40", "DELETE:");
  121.         rc = SysINI('USER', "XFolder_0_41", "DELETE:");
  122.         rc = SysINI('USER', "XFolder_0_42", "DELETE:");
  123.         rc = SysINI('USER', "XFolder 0.5x", "DELETE:");
  124.         rc = SysINI('USER', "XFolder07", "DELETE:");
  125.         rc = SysINI('USER', "XFolder7", "DELETE:");
  126.  
  127.         /* set INI data for this version */
  128.         rc = SysINI('USER', IniKey, "XFolderPath", mydir||'0'x);
  129.         rc = SysINI('USER', IniKey, "Language", LanguageCode||'0'x);
  130.         rc = SysINI('USER', IniKey, "JustInstalled", '1'||'0'x);
  131.         rc = SysINI('USER', IniKey, "Version", XFolderVersion||'0'x);
  132.  
  133.         /* remove WPS classes that might already be registered */
  134.         callxhelpStr "unregisteringOldMsg";
  135.         call pause
  136.  
  137.         say "";
  138.         call charout , "Deregistering XFldWPS: "
  139.         if (SysDeregisterObjectClass("XFldWPS")) then
  140.             Say "OK";
  141.             else Say "not found";
  142.         call charout , "Deregistering XFldStartup: "
  143.         if (SysDeregisterObjectClass("XFldStartup")) then
  144.             Say "OK";
  145.             else Say "not found";
  146.         call charout , "Deregistering XFldShutdown: "
  147.         if (SysDeregisterObjectClass("XFldShutdown")) then
  148.             Say "OK";
  149.             else Say "not found";
  150.         "bin\repclass.exe WPSystem XFldSystem"
  151.         "bin\repclass.exe WPProgram XFldProgram"
  152.         "bin\repclass.exe WPDisk XFldDisk"
  153.         "bin\repclass.exe WPDataFile XFldDataFile"
  154.         "bin\repclass.exe WPDesktop XFldDesktop"
  155.         "bin\repclass.exe WPFolder XFolder"
  156.         "bin\repclass.exe WPFileSystem XFldFileSystem"
  157.         "bin\repclass.exe WPObject XFldObject"
  158.  
  159.         /* install classes for this version */
  160.         say "";
  161.         callxhelpStr "registeringNewMsg";
  162.         call pause
  163.  
  164.         say "";
  165.         "bin\repclass.exe WPFolder XFolder" mydir||"\bin\xfldr.dll";
  166.         "bin\repclass.exe WPObject XFldObject" mydir||"\bin\xfldr.dll";
  167.         /* "bin\repclass.exe WPFileSystem XFldFileSystem" mydir||"\bin\xfldr.dll"; */
  168.         "bin\repclass.exe WPDataFile XFldDataFile" mydir||"\bin\xfldr.dll";
  169.         "bin\repclass.exe WPDisk XFldDisk" mydir||"\bin\xfldr.dll";
  170.         "bin\repclass.exe WPDesktop XFldDesktop" mydir||"\bin\xfldr.dll";
  171.         say "";
  172.         call charout , "Registering XFldSystem: "
  173.         if (SysRegisterObjectClass("XFldSystem", mydir||"\bin\xfldr.dll")) then
  174.             Say "OK";
  175.             else Say "failed";
  176.         call charout , "Registering XFldWPS: "
  177.         if (SysRegisterObjectClass("XFldWPS", mydir||"\bin\xfldr.dll")) then
  178.             Say "OK";
  179.             else Say "failed";
  180.         call charout , "Registering XFldStartup: "
  181.         if (SysRegisterObjectClass("XFldStartup", mydir||"\bin\xfldr.dll")) then
  182.             Say "OK";
  183.             else Say "failed";
  184.         call charout , "Registering XFldShutdown: "
  185.         if (SysRegisterObjectClass("XFldShutdown", mydir||"\bin\xfldr.dll")) then
  186.             Say "OK";
  187.             else Say "failed";
  188.  
  189.         /* check for Object Desktop TSEnhFolder */
  190.         call SysQueryClassList "ClassList.";
  191.         if (ClassList.0 > 0) then
  192.             do i = 1 to ClassList.0
  193.                 parse var ClassList.i Class DLL
  194.                 if (Class = "TSEnhFolder") then do
  195.                     callxhelpStr "QueryODMsg";
  196.                     key = ''
  197.                     do until (pos(key,"YN") > 0)
  198.                        key = translate(SysGetKey("NOECHO"))
  199.                     end;
  200.                     say key;
  201.                     say "";
  202.                     if (key = "Y") then do
  203.                         /* remove TSEnhFolder and undo replacement */
  204.                         "bin\repclass.exe WPFolder TSEnhFolder"
  205.                         /* and register and replace again;
  206.                            OBJDEFLD.DLL should be on the LIBPATH */
  207.                         "bin\repclass.exe WPFolder TSEnhFolder OBJDEFLD"
  208.                         callxhelpStr "ODDeregdMsg";
  209.                         "pause >NUL"
  210.                     end;
  211.                 end;
  212.             end
  213.  
  214.         /* restart WPS? */
  215.         callxhelpStr "shutdownMsg";
  216.         key = ''
  217.         do until (pos(key,"YN") > 0)
  218.            key = translate(SysGetKey("NOECHO"))
  219.         end /* do */
  220.         Say key
  221.         if (key = "Y") then
  222.             "bin\wpsreset -D"
  223.         else do
  224.             callxhelpStr "howtoMsg";
  225.             "pause >NUL"
  226.         end
  227.         exit
  228.     end
  229.  
  230.     when (key = "D") then do
  231.         /* UNREGISTER */
  232.  
  233.         callxhelpStr "unregisteringOldMsg";
  234.  
  235.         say "";
  236.         call charout , "Deregistering XFldWPS: "
  237.         if (SysDeregisterObjectClass("XFldWPS")) then
  238.             Say "OK";
  239.             else Say "not found";
  240.         call charout , "Deregistering XFldStartup: "
  241.         if (SysDeregisterObjectClass("XFldStartup")) then
  242.             Say "OK";
  243.             else Say "not found";
  244.         call charout , "Deregistering XFldShutdown: "
  245.         if (SysDeregisterObjectClass("XFldShutdown")) then
  246.             Say "OK";
  247.             else Say "not found";
  248.         "bin\repclass.exe WPSystem XFldSystem"
  249.         "bin\repclass.exe WPProgram XFldProgram"
  250.         "bin\repclass.exe WPDisk XFldDisk"
  251.         "bin\repclass.exe WPDataFile XFldDataFile"
  252.         "bin\repclass.exe WPDesktop XFldDesktop"
  253.         "bin\repclass.exe WPFolder XFolder"
  254.         "bin\repclass.exe WPFileSystem XFldFileSystem"
  255.         "bin\repclass.exe WPObject XFldObject"
  256.  
  257.         /* clean up INIs too? */
  258.         say "";
  259.         callxhelpStr "removeIniMsg";
  260.         key = ''
  261.         do until (pos(key,"YN") > 0)
  262.            key = translate(SysGetKey("NOECHO"))
  263.         end /* do */
  264.         Say key
  265.         if (key = "Y") then do
  266.             /* XFolder keys in OS2.INI */
  267.             rc = SysINI('USER', IniKey, "DELETE:");
  268.             /* XFolder sounds in MMPM.INI */
  269.             MMINI = GetBootDrive()||"\MMOS2\MMPM.INI";
  270.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "555", "DELETE:");
  271.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "556", "DELETE:");
  272.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "558", "DELETE:");
  273.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "559", "DELETE:");
  274.             rc = SysINI(MMINI, "MMPM2_AlarmSounds", "560", "DELETE:");
  275.         end;
  276.  
  277.         /* restart WPS? */
  278.         say "";
  279.         callxhelpStr "shutdownMsg";
  280.         key = ''
  281.         do until (pos(key,"YN") > 0)
  282.            key = translate(SysGetKey("NOECHO"))
  283.         end /* do */
  284.         Say key
  285.         if (key = "Y") then
  286.             "bin\wpsreset -D"
  287.         exit
  288.     end;
  289.  
  290.     when (key = "X") then
  291.         exit;
  292. end /* select */
  293.  
  294. /* wrong key pressed: keep looping */
  295. say ""
  296. signal loop;
  297.  
  298. halt:
  299. say '0d0a'x'Installation aborted!'
  300. exit
  301.  
  302. createObjects:
  303.         callxhelpStr "creatingObjMsg"
  304.         "call install\crobj"LanguageCode".cmd"
  305. return;
  306.  
  307. GetBootDrive: procedure
  308.     parse upper value VALUE( "PATH",, "OS2ENVIRONMENT" ) with "\OS2\SYSTEM" -2 boot_drive +2
  309. return boot_drive
  310.  
  311. pause:  procedure
  312. key = ""
  313. do while (key = "")
  314.    key = SysGetKey("NOECHO")
  315. end /* do */
  316. say ""
  317. return
  318.  
  319. strReplace: procedure
  320.     /* syntax: result = strReplace(str, old, new) */
  321.     /* will replace a with b in oldstr */
  322.     parse arg str, old, new
  323.     p = pos(old, str)
  324.     if (p > 0) then
  325.         str = left(str, p-1)||new||substr(str,p+length(old))
  326. return str
  327.  
  328.