A friend of mine helped me improve my WPI (v6.5) by adding the following: I'd love to see these features included in the source of future releases. Code follows below. 1. Added GetFirewallProduct() and GetAntivirusProduct() methods. (registry_dos.js) 2. Fixed the code for getting the optical drive letter in defaultWPI(). Now defaults to using WMI, and reverts to the old way if WMI is not present. (core.js) 3. Modified getOSver() to use WMI, and to cache the result since this function is called VERY often. (registry_dos.js, globals.js) 4. Cached the result of getSPver() as well. (registry_dos.js, rev 19; globals.js) 5. Added WMI constants to globals.js. (globals.js) 6. Added GetFirewallProduct() and GetAntivirusProduct() methods to condition dropdown boxes. (configwizardtemplate_config.htm) -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ core.js - new defaultWPI function -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // 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% // First try getting the CD Drive letter from WMI... try { var objWMIService = GetObject("winmgmts:\\\\" + "." + "\\root\\cimv2"); var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType=5", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); var enumItems = new Enumerator(colItems); for (; !enumItems.atEnd(); enumItems.moveNext()) { var objItem = enumItems.item(); cddrv = objItem.DeviceID + "\\"; break; } } catch (ex) // if WMI doesn't work, then revert to the old way { // NOTE: THIS METHOD DOES NOT WORK WITH VISTA li = GetDriveLetters(4); for (i=0; i<li.length; i++) { if (FileExists(li[i]+'\\WPI.HTA') || FileExists(li[i]+'\\WIN51') || FileExists(li[i]+'\\I386\\DRIVER.CAB') || FileExists(li[i]+'\\Sources\\install.wim')) cddrv = li[i]; } if (cddrv=="") { a = fso.GetAbsolutePathName("."); while (a.length>=3) { if (FileExists(a+'\\WPI.HTA')) { cddrv=a; break; } if (a.length==3) break; a = a + "\\.."; a = fso.GetAbsolutePathName(a); } } if (cddrv=="") { try { // this registry value may not exist, and will throw an exception in that case cddrv = WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup\\SourcePath") + "\\"; cddrv = cddrv.substr(0,3); } catch (ex) { ; } } } // %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; x<arrOSLang.length; x++) { if (arrOSLang[x].LCID == DtoH) { oslang=arrOSLang[x].TLA; break; } } } -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ globals.js - added to end of file -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // WMI constants var wbemFlagReturnImmediately = 0x10; var wbemFlagForwardOnly = 0x20; // registry_dos.js var NOT_FOUND = "Not found"; var szOSVerCache = NOT_FOUND; var szServicePackCache = NOT_FOUND; -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ registry_dos.js - new getOSver() and getSPver() -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ function getOSver() { position="registry_dos.js"; whatfunc="getOSver()"; if ( szOSVerCache == NOT_FOUND ) // this function is called often - get it once and cache the result { var ver = ""; try // try using WMI first... { var objWMIService = GetObject("winmgmts:\\\\" + arrComputers[i] + "\\root\\CIMV2"); var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); var enumItems = new Enumerator(colItems); for (; !enumItems.atEnd(); enumItems.moveNext()) { var objItem = enumItems.item(); ver = objItem.Caption; if (ver.indexOf("Vista") >= 0) szOSVerCache = "Vista"; if (ver.indexOf("Server 2003") >= 0) szOSVerCache = "03"; if (ver.indexOf("XP") >= 0) szOSVerCache = "XP"; if (ver.indexOf("2000") >= 0) szOSVerCache = "2K"; // WMI is not likely to be installed on older OS's - if WMI is not present, then we revert to the old code... } } catch (ex) // if WMI doesn't work, try checking the registry directly { try { ver=WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\CurrentVersion"); } catch (ex1) { try { ver=WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Version"); } catch (ex2) { ; } } if (ver=="6.0") szOSVerCache ="Vista"; if (ver=="5.2") szOSVerCache ="03"; if (ver=="5.1") szOSVerCache ="XP"; if (ver=="5.0") szOSVerCache ="2K"; if (ver=="4.0") szOSVerCache ="NT"; if (ver=="Windows 98") szOSVerCache ="98"; if (ver=="Windows Millennium Edition") szOSVerCache ="ME"; if (ver=="Windows 95") szOSVerCache = "95"; } } return szOSVerCache; } function getSPver() { position="registry_dos.js"; whatfunc="getSPver()"; if ( szServicePackCache == NOT_FOUND ) { var sp = ""; try { sp=WshShell.RegRead("HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\CSDVersion"); } catch (ex) { ; } if (sp != "") { szServicePackCache = sp.substr(sp.length-1,1); } } return szServicePackCache; } -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ registry_dos.js - newly added firewall and antivirus methods -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ //============================================================================= // Firewall and AntiVirus methods // // These functions use WMI to check what products are registered with the // Windows Security Center. It is possible that a Firewall or AntiVirus product // is installed, but is not registered with the Windows Security Center // (particularly with older legacy applications). // // These methods are not likely to be called often, so probably no need to cache. // function getFirewallProduct() { position="registry_dos.js"; whatfunc="getFirewallProduct()"; var FirewallProductName=""; try { var objWMIService = GetObject("winmgmts:\\\\" + "." + "\\root\\SecurityCenter"); var colItems = objWMIService.ExecQuery("SELECT * FROM FirewallProduct", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); var i = 0; var enumItems = new Enumerator(colItems); for (; !enumItems.atEnd(); enumItems.moveNext()) { i = i + 1; var objItem = enumItems.item(); FirewallProductName = objItem.displayName; break; // just get the first one and return } } catch (ex) { // window.alert("getFirewallProduct - EXCEPTION CAUGHT!"); // for testing purposes ; } return FirewallProductName; } function getAntiVirusProduct() { position="registry_dos.js"; whatfunc="getAntiVirusProduct()"; var AVProduct=""; try { var objWMIService = GetObject("winmgmts:\\\\" + "." + "\\root\\SecurityCenter"); var colItems = objWMIService.ExecQuery("SELECT * FROM AntiVirusProduct", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); var enumItems = new Enumerator(colItems); for (; !enumItems.atEnd(); enumItems.moveNext()) { var objItem = enumItems.item(); AVProduct = objItem.displayName; } } catch (ex) { // window.alert("getAntiVirusProduct - EXCEPTION CAUGHT!"); // for testing purposes ; } return AVProduct; } -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ configwizardtemplate_config.htm - added following to both cboConditions1 and cboConditions2 sections for dropdown boxes. -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ <optgroup label="Security"> <option value="getAntiVirusProduct()">getAntiVirusProduct()</option> <option value="getFirewallProduct()">getFirewallProduct()</option> </optgroup>