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