// // Date Last Modified: June 12th, 2007 // // Modified By: Kelsenellenelvian // // Set some specific environment variables for WPI function defaultWPI() { position="core.js"; whatfunc="defaultWPI()"; // %wpipath% wpipath = unescape(document.location); wpipath = wpipath.substring(0,wpipath.lastIndexOf("/")); wpipath = wpipath.replace("file:///","").replace(/\//g,"\\"); // Universal Silent Switch Finder USSFcmd=wpipath+"\\Tools\\USSF.exe"; // %root% root=fso.GetParentFolderName(wpipath); // %dospath% if (FileExists(sysdir + "$winnt$.inf")) { var winntinf=fso.OpenTextFile(sysdir + "$winnt$.inf", 1); // It's recorded in the 'dospath' directive of the [data] section of \system32\$winnt$.inf. var matches = winntinf.ReadAll().match(/\ndospath=(.*)/i); winntinf.Close(); if (matches) { dospath=matches[1]; if (dospath.substring(dospath.length - 2, dospath.length - 1)=="\\")//dospath may have a trailing slash ... or not (depending on the location) dospath = dospath.substring(0, dospath.length - 2); // So let's remove it if it's there } } // FYI: x64 stores this file in system32 but since the app that runs your script (mshta.exe) is only 32-bit it references SysWOW64 instead of system32 // %HDD% var a, i, li = new Array(); hdd=""; if (i=wpipath.indexOf(":") != -1 && !ResumeInstall) { var temp; temp=wpipath.substr(0,2); a=DriveType(temp); if (a !="UNKNOWN" && a !="CDROM") // Not UNKNOWN and not CDROM hdd=temp; else hdd=""; } // %CDROM% li = GetDriveLetters(4); for (i=0; i=3) { if (FileExists(a+'\\WPI.HTA')) { cddrv=a; break; } if (a.length==3) break; a = a + "\\.."; a = fso.GetAbsolutePathName(a); } } if (cddrv=="") { cddrv = WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup\\SourcePath") + "\\"; cddrv = cddrv.substr(0,3); } // %OSLANG% var sLang = '', Enum, DtoH; CreateLocalArray(); // OSLanguage = 1033, 1036, .... var OSProps = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem"); // Language ID in Dec sLang = new Enumerator(OSProps).item(); Enum = sLang.OSLanguage; DtoH = DecToHex(Enum); while (DtoH.length<4) DtoH = "0" + DtoH+""; for (var x=0; x15) { d>>=4; h=hD.substr(d&15,1)+h; } return h; } function SetScriptWaitTimeout(timeout) // max is 4294967295 { position="core.js"; whatfunc="SetScriptWaitTimeout()"; var val=0; var KeyBase="HKCU\\Software\\Microsoft\\Internet Explorer\\Styles\\MaxScriptStatements"; try { if (timeout<0) { try { WshShell.RegDelete(KeyBase); return; } catch(ex) { ; } } try { val=WshShell.RegRead(KeyBase); } catch (exc) { if (timeout==0 || !timeout) timeout=0x7fffffff; WshShell.RegWrite(KeyBase,timeout,"REG_DWORD"); } } catch (ex2) { ; } } function ReplacePath(v) { position="core.js"; whatfunc="ReplacePath()"; var i, rs = new String(v); rs = rs.replace(/%wpipath%/gi, wpipath); // Replace WPI's special environment variables rs = rs.replace(/%root%/gi, root); // WPI parent folder if (hdd=="") rs = rs.replace(/%cdrom%/gi, cddrv); // started from cdrom else rs = rs.replace(/%cdrom%/gi, hdd); // not started from cdrom rs = rs.replace(/%sysdir%/gi, sysdir); // same as before rs = rs.replace(/%dospath%/gi, dospath); // new variable rs = rs.replace(/%oslang%/gi, oslang); // operating system language code rs = rs.replace(/%reboot%/gi, 'shutdown.exe -r -f -t '); // force a reboot after X seconds rs = rs.replace(/%reboot%/gi, 'shutdown.exe -r -f -t 0'); // force a reboot now rs = rs.replace(/%sleep%/gi, wpipath+"\\Tools\\Sleep.exe"); // Pause for x seconds rs = rs.replace(/%extract%/gi, '"'+wpipath+"\\WPIScripts\\ExtractToPath.vbs"+'"'); // Archive Extraction // Replace other (standard) environment variables (either global or defined in the process calling WPI) var envarname, envvars = rs.match(/%[^ %\f\n\r\t\v]+%/gi); // find ALL substrings enclosed in '%' and not containing '%' itself or a white space character if (envvars) // if any match { for (i=0; i