home *** CD-ROM | disk | FTP | other *** search
/ Chip 2009 November / Chip_2009.11_CD.iso / Chip_WPI / WPIScripts / reboot.js < prev    next >
Encoding:
JavaScript  |  2007-11-13  |  5.7 KB  |  161 lines

  1. //
  2. // Date Last Modified: November 13, 2007
  3. //
  4. // Modified By: Michael Mims (zorphnog), Mark Ritter
  5. //
  6.  
  7.  
  8. function OpenRebootFile()
  9. {
  10.     position="reboot.js";
  11.     whatfunc="OpenRebootFile()";
  12.  
  13.     var rebootFile;
  14.  
  15.     if (RebootInstallationLog)
  16.     {
  17.         rebootFile=ReplacePath(DefaultRebootFilePath);
  18.         if (ResumeInstall)
  19.         {
  20.             try
  21.             {
  22.                 rbfHandle = fso.OpenTextFile(rebootFile,8,false);
  23.             }
  24.             catch (ex)
  25.             {
  26.                 alert(getText(NotOpenRebootFile)+"\n"+rebootFile);
  27.                 ExitWPI();
  28.             }
  29.         }
  30.         else if (RebootEntryFound)
  31.         {
  32.             try 
  33.             {
  34.                 rbfHandle = fso.CreateTextFile(rebootFile,true);
  35.                 rbfHandle.WriteLine("// Reboot Configuration File");
  36.                 rbfHandle.WriteLine("// Install process started at: "+LogTimeStamp());
  37.                 rbfHandle.WriteLine("\r\nprb=0;\r\n");
  38.             }
  39.             catch (ex) 
  40.             { 
  41.                 alert(getText(CouldNotCreateLogFile)+"\r\n"+rebootFile);
  42.                 RebootInstallationLog=false;
  43.  
  44.                 return;
  45.             }
  46.         }
  47.     }
  48. }
  49.  
  50.  
  51. function RebootEntry(rbProg)
  52. {
  53.     position="reboot.js"; 
  54.     whatfunc="RebootEntry()";
  55.  
  56.     var txt;
  57.  
  58.     if (RebootInstallationLog && RebootEntryFound)
  59.     {
  60.         rbfHandle.WriteLine("programs[prb] = new program(prb);");
  61.         rbProg.prog != null ? rbfHandle.WriteLine("programs[prb].prog=["+GetConfigValue(rbProg.prog.toString())+"];") : null;
  62.         rbProg.ordr != null ? rbfHandle.WriteLine("programs[prb].ordr=["+GetConfigValue(rbProg.ordr.toString(),1)+"];") : null;
  63.  
  64.         txt=GetConfigValue(rbProg.uid.toString());
  65.         txt=txt.replace(/ */g,"");
  66.         rbProg.uid != null ? rbfHandle.WriteLine("programs[prb].uid=["+GetConfigValue(txt,1)+"];") : null;
  67.  
  68.         rbProg.regb != null ? rbfHandle.WriteLine("programs[prb].regb=["+GetConfigValue(rbProg.regb[0].toString())+"];") : null;
  69.         rbProg.cmd1 != null ? rbfHandle.WriteLine("programs[prb].cmd1=["+GetConfigValue(rbProg.cmd1[0].toString())+"];") : null;
  70.         rbProg.cmd2 != null ? rbfHandle.WriteLine("programs[prb].cmd2=["+GetConfigValue(rbProg.cmd2[0].toString())+"];") : null;
  71.         rbProg.cmd3 != null ? rbfHandle.WriteLine("programs[prb].cmd3=["+GetConfigValue(rbProg.cmd3[0].toString())+"];") : null;
  72.         rbProg.cmd4 != null ? rbfHandle.WriteLine("programs[prb].cmd4=["+GetConfigValue(rbProg.cmd4[0].toString())+"];") : null;
  73.         rbProg.cmd5 != null ? rbfHandle.WriteLine("programs[prb].cmd5=["+GetConfigValue(rbProg.cmd5[0].toString())+"];") : null;
  74.         rbProg.cmd6 != null ? rbfHandle.WriteLine("programs[prb].cmd6=["+GetConfigValue(rbProg.cmd6[0].toString())+"];") : null;
  75.         rbProg.cmd7 != null ? rbfHandle.WriteLine("programs[prb].cmd7=["+GetConfigValue(rbProg.cmd7[0].toString())+"];") : null;
  76.         rbProg.cmd8 != null ? rbfHandle.WriteLine("programs[prb].cmd8=["+GetConfigValue(rbProg.cmd8[0].toString())+"];") : null;
  77.         rbProg.cmd9 != null ? rbfHandle.WriteLine("programs[prb].cmd9=["+GetConfigValue(rbProg.cmd9[0].toString())+"];") : null;
  78.         rbProg.cmd10 != null ? rbfHandle.WriteLine("programs[prb].cmd10=["+GetConfigValue(rbProg.cmd10[0].toString())+"];") : null;
  79.         rbProg.rega != null ? rbfHandle.WriteLine("programs[prb].rega=["+GetConfigValue(rbProg.rega[0].toString())+"];") : null;
  80.         rbfHandle.WriteLine("programs[prb].success=false;");
  81.         rbfHandle.WriteLine("programs[prb].fail=false;");
  82.         rbfHandle.WriteLine("prb++;\r\n");
  83.     }
  84. }
  85.  
  86. function ScanForEntries(prog)
  87. {
  88.     position="reboot.js";
  89.     whatfunc="ScanForEntries()";
  90.  
  91.     var numEntries=12, needReboot=false;
  92.  
  93.     prog.regb != null ? null : numEntries--;
  94.     prog.cmd1 != null ? (prog.cmd1[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  95.     prog.cmd2 != null ? (prog.cmd2[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  96.     prog.cmd3 != null ? (prog.cmd3[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  97.     prog.cmd4 != null ? (prog.cmd4[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  98.     prog.cmd5 != null ? (prog.cmd5[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  99.     prog.cmd6 != null ? (prog.cmd6[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  100.     prog.cmd7 != null ? (prog.cmd7[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  101.     prog.cmd8 != null ? (prog.cmd8[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  102.     prog.cmd9 != null ? (prog.cmd9[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  103.     prog.cmd10 != null ? (prog.cmd10[0].toUpperCase().indexOf("%REBOOT%") == 0 ? needReboot=true : null) : numEntries--;
  104.     prog.rega != null ? null : numEntries--;
  105.  
  106.     RebootEntryFound ? null : RebootEntryFound=needReboot;
  107.     numCommands += numEntries;
  108. }
  109.  
  110. function WriteRebootSuccess(i, flag)
  111. {
  112.     position="reboot.js";
  113.     whatfunc="WriteRebootSuccess()";
  114.  
  115.     if ((RebootInstallationLog && RebootEntryFound) || (RebootInstallationLog && ResumeInstall))
  116.         rbfHandle.WriteLine("programs["+i+"].success="+flag+";");
  117. }
  118.  
  119.  
  120. function WriteRebootFail(i, flag)
  121. {
  122.     position="reboot.js";
  123.     whatfunc="WriteRebootSuccess()";
  124.  
  125.     if ((RebootInstallationLog && RebootEntryFound) || (RebootInstallationLog && ResumeInstall))
  126.         rbfHandle.WriteLine("programs["+i+"].fail="+flag+";");
  127. }
  128.  
  129.  
  130. function DeleteRebootFile()
  131. {
  132.     position="reboot.js"
  133.     whatfunc="DeleteRebootFile()";
  134.  
  135.     var rebootFile;
  136.  
  137.     rebootFile = ReplacePath(DefaultRebootFilePath);
  138.     if (FileExists(rebootFile) && !RebootInstallationLog)
  139.     {
  140.         cmdLine='cmd /c del /f /q "'+rebootFile+'"';
  141.         try
  142.         {
  143.             WshShell.Run(cmdLine,0,true);
  144.         }
  145.         catch (ex)
  146.         {
  147.             alert(getText(CouldNotDeleteFile)+"\r\n"+rebootFile);
  148.         }
  149.     }
  150. }
  151.  
  152.  
  153. function CloseRebootFile()
  154. {
  155.     position="reboot.js";
  156.     whatfunc="CloseRebootFile()";
  157.  
  158.     if (RebootInstallationLog && rbfHandle != null)
  159.         rbfHandle.Close();
  160. }
  161.