home *** CD-ROM | disk | FTP | other *** search
/ Chip 2009 November / Chip_2009.11_CD.iso / Chip_WPI / WPIScripts / installer_log.js < prev    next >
Encoding:
JavaScript  |  2006-10-24  |  3.1 KB  |  144 lines

  1. //
  2. // Date Last Modified: Monday, October 02, 2006
  3. //
  4. // Modified By: Mark Ritter (mritter) & Michael Mims (zorphnog)
  5. //
  6.  
  7.  
  8. function OpenLogFile()
  9. {
  10.     position="installer_log.js";
  11.     whatfunc="OpenLogFile()";
  12.  
  13.     var logFile;
  14.  
  15.     if (LogInstallation)
  16.     {
  17.         if (LogPath=="")
  18.         {
  19. //            alert(getText(NoLogFileSpecified)+"\n"+DefaultLogPath);
  20.             LogPath=DefaultLogPath;
  21.         }
  22.         
  23.         logFile=ReplacePath(LogPath[0]);
  24.         try 
  25.         {
  26.             WshShell.regWrite("HKEY_CURRENT_USER\\Software\\WPI\\LogPath",LogPath,"REG_SZ");
  27.         }
  28.         catch (ex)
  29.         {;}
  30.  
  31.         if (ResumeInstall)
  32.         {
  33.             try
  34.             {
  35.                 logHandle = fso.OpenTextFile(logFile,8,false);
  36.             }
  37.             catch (ex)
  38.             {
  39. //                alert(getText(CouldNotOpenLogFile)+"\r\n"+logFile);
  40.                 LogInstallation=false;
  41.  
  42.                 return;
  43.             }
  44.         }
  45.         else
  46.         {
  47.             try 
  48.             {
  49.                 logHandle = fso.CreateTextFile(logFile,true);
  50.                 logHandle.WriteLine(getText(WPIInstallLogFile)+"\r\n");
  51.                 logHandle.WriteLine(getText(InstallProcessStarted)+" "+LogTimeStamp());
  52.  
  53.                 LogGlobalVariables();            
  54.             }
  55.             catch (ex) 
  56.             { 
  57. //                alert(getText(CouldNotCreateLogFile)+"\r\n"+logFile);
  58.                 LogInstallation=false;
  59.     
  60.                 return;
  61.             }
  62.         }
  63.     }
  64. }
  65.  
  66.  
  67. function LogGlobalVariables()
  68. {
  69.     position="installer_log.js";      
  70.     whatfunc="LogGlobalVariables()";
  71.  
  72.     WriteLogLinePlain("\r\nGlobal variables:");
  73.     WriteLogLinePlain("   %OSLANG%="+oslang);
  74.     WriteLogLinePlain("   %WPIPATH%="+wpipath);
  75.     WriteLogLinePlain("   %ROOT%="+root);
  76.     WriteLogLinePlain("   %CDROM%="+cddrv);
  77.     WriteLogLinePlain("   %DOSPATH%="+dospath);
  78.     WriteLogLinePlain("   %SYSTEMDRIVE%="+sysdrv);
  79.     WriteLogLinePlain("   %WINDIR%="+windir);
  80.     WriteLogLinePlain("   %PROGRAMFILES%="+programfiles);
  81.     WriteLogLinePlain("   %TEMP%="+temp);
  82.     WriteLogLinePlain("   %SYSDIR%="+sysdir);
  83.     WriteLogLinePlain("   %ALLUSERSPROFILE%="+allusersprofile);
  84.     WriteLogLinePlain("   %USERPROFILE%="+userprofile);
  85.     WriteLogLinePlain("   %APPDATA%="+appdata);
  86.     WriteLogLinePlain("   %COMMONPROGRAMFILES%="+commonprogramfiles);
  87. }
  88.  
  89.  
  90. function LogTimeStamp()
  91. {
  92.     position="installer_log.js";      
  93.     whatfunc="LogTimeStamp()";
  94.  
  95.     var DateStamp = new Date();
  96.  
  97.     return DateStamp.toLocaleString();
  98. }
  99.  
  100.  
  101. function StartLogEntry(prog)
  102. {
  103.     position="installer_log.js";      
  104.     whatfunc="StartLogEntry()";
  105.  
  106.     if (LogInstallation)
  107.         logHandle.WriteLine("\r\n-----\r\n\r\n"+LogTimeStamp()+"\r\n   Program: "+prog.prog+"\r\n   UID: "+prog.uid+"\r\n   Order: "+prog.ordr+"\r\n   Category: "+prog.cat);
  108. }
  109.  
  110.  
  111. function WriteLogLine(logTxt)
  112. {
  113.     position="installer_log.js";      
  114.     whatfunc="WriteLogLine()";
  115.  
  116.     if (LogInstallation)
  117.         logHandle.WriteLine("   "+LogTimeStamp()+"\r\n   "+logTxt);
  118. }
  119.  
  120.  
  121. function WriteLogLinePlain(logTxt)
  122. {
  123.     position="installer_log.js";      
  124.     whatfunc="WriteLogLinePlain()";
  125.  
  126.     if (LogInstallation)
  127.         logHandle.WriteLine(logTxt);
  128. }
  129.  
  130.  
  131. function CloseLogFile()
  132. {
  133.     position="installer_log.js";      
  134.     whatfunc="CloseLogFile()";
  135.  
  136.     if (LogInstallation)
  137.     {
  138.         logHandle.WriteLine("\r\n-----");
  139.         logHandle.WriteLine("\r\n"+getText(InstallProcessFinished)+" "+LogTimeStamp());
  140.     
  141.         logHandle.Close();
  142.     }
  143. }
  144.