Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


gt7599a

Member
  • Content Count

    10
  • Donations

    $0.00 
  • Joined

  • Last visited

Community Reputation

0 Neutral

About gt7599a

  1. 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>
  2. An error & solution from two friends of mine using a WPI install I put together. 1) When you first start the WPI (click start install), it fires this error message about not have permission to write to "c:\rb_config.js", but still starts and runs. 2) When the computer restarts mid WPI install, the WPI does not restart upon restart, as it does and should on XP. When you go and manually restart the program, it asks if you want to resume, but when you do, it gives this error "undefined; C:\rb_config.js; undefined" and then you have to restart the WPI from scratch. In globals.js Find the section that looks like this: // reboot.js var prb=0; var rbfHandle=null; var DefaultRebootFilePath='%systemdrive%\\rb_config.js'; a suggested modification: Change %systemdrive% to %userprofile% which should be compatible with both Vista & XP and get around the Vista permissions issue. Not sure about w2k, 98, etc. Ed
  3. I think I may have fixed the problem. One of my early program entries started with cmd2, going cmd2 - cmd4. Using a text editor I manually changed it to go cmd1 - cmd3, reordered the programs according to install order and now it seems to be working. Weird Ed
  4. I took a config.js file under WPI 5.4 started using it under 6.0 and now under 6.1 The file works but many time when I open WPI cmd entires that weren't originally there under 6.0 there get created or recreated. I've removed them both from within WPI & manually with a text editor and they seem to reappear without reason. I've manually edited config.js to reorder entries under 5.4, 6.0 & 6.1 and hadn't seen the problem prior to 6.1. When I click on the select file button on the right hand side of command #7 I get a javaScript error Report saying Message: 'document.getElementById(...)' is null or not an object Url: file:///D:/WPI/WPI.hta File: configwizard.js Function: clearcmd7Browse() Line: 1094 3 Specific examples with the undeleting elements in red prog[pn]=['Adobe Reader 8.1']; ordr[pn]=[641]; desc[pn]=['Installs Acrobat Reader 8.1 English, Chinese Simplified & Tradition, Korean & Japenese Font packs. Removes Acrobat icon from desktop.']; uid[pn]=['ADOBEREADER8']; dflt[pn]=['yes']; cat[pn]=['Applications']; forc[pn]=['no']; configs[pn]=['Apps']; cmd1[pn]=['msiexec.exe /i "%wpipath%\\Install\\AcrobatReader8.0English\\AdbeRdr810_en_US.msi" /qb']; cmd2[pn]=['msiexec.exe /i "%wpipath%\\Install\\AcrobatReader8.0English\\FontPack80_zh_CN.msi" /qb']; cmd3[pn]=['msiexec.exe /i "%wpipath%\\Install\\AcrobatReader8.0English\\FontPack80_zh_TW.msi" /qb']; cmd4[pn]=['msiexec.exe /i "%wpipath%\\Install\\AcrobatReader8.0English\\FontPack80_ko_KR.msi" /qb']; cmd5[pn]=['msiexec.exe /i "%wpipath%\\Install\\AcrobatReader8.0English\\FontPack80_ja_JP.msi" /qb']; cmd6[pn]=['DELETE "%ALLUSERSPROFILE%\\Desktop\\Adobe Reader 8.lnk"']; [color="#FF0000"]cmd7[pn]=['msiexec.exe /i "%wpipath%\\Install\\AcrobatReader8.0English\\FontPack80_zh_TW.msi" /qb']; cmd8[pn]=['msiexec.exe /i "%wpipath%\\Install\\AcrobatReader8.0English\\FontPack80_ko_KR.msi" /qb']; cmd9[pn]=['msiexec.exe /i "%wpipath%\\Install\\AcrobatReader8.0English\\FontPack80_ja_JP.msi" /qb']; cmd10[pn]=['DELETE "%ALLUSERSPROFILE%\\Desktop\\Adobe Reader 8.lnk"']; [/color]pn++; prog[pn]=['CCleaner']; ordr[pn]=[701]; desc[pn]=['Version137, no toolbar']; uid[pn]=['CCLEANER']; dflt[pn]=['yes']; cat[pn]=['Applications']; forc[pn]=['no']; configs[pn]=['Apps']; cmd1[pn]=['"%wpipath%\\Install\\CCleaner\\ccsetup137_slim.exe" /S']; cmd2[pn]=['DELETE "%USERSPROFILE%\\Desktop\\CCleaner.lnk"']; cmd3[pn]=['DELETE "%ALLUSERSPROFILE%\\Desktop\\CCleaner.lnk"']; [color="#FF0000"]cmd7[pn]=['DELETE "%ALLUSERSPROFILE%\\Desktop\\CCleaner.lnk"']; [/color]pn++; prog[pn]=['Skype']; ordr[pn]=[702]; desc[pn]=['Version 3']; uid[pn]=['SKYPE']; dflt[pn]=['yes']; cat[pn]=['Applications']; forc[pn]=['no']; configs[pn]=['Apps']; cmd1[pn]=['"%wpipath%\\Install\\Skype\\SkypeSetup.exe" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-']; cmd2[pn]=['DELETE "%ALLUSERSPROFILE%\\Desktop\\Skype.lnk"']; cmd3[pn]=['DELETE "%USERSPROFILE%\\Desktop\\Skype.lnk"']; [color="#FF0000"]cmd7[pn]=['DELETE "%USERSPROFILE%\\Desktop\\Skype.lnk"']; [/color]pn++; Is this a WPI 6.1 bug or have I inadvertently put some character(s) in the config.js that are causing the issue? Any thoughts, suggestions, or references to help files I've overlooked would be appreciated. Ed p.s. I'm very glad I've found WPI, it's going to shave a LOT of time off the installs I do for work. so thanks to the team and contributers for all the hard work. config.js
  5. Just a note for anyone needing the getOSlang() command you will need to manually add the following to core.js courtesy zorphnog function getOSlang() { position="core.js"; whatfunc="getOSlang()"; return oslang; } Once again, thanks to Kel et al for their hard work. Ed
  6. I'm having an error similar to parkerkane but mine does it on every reboot, whether the application calls the reboot itself (e.g. XP SP2) or when I call it through WPI using the %reboot% command, with or without time. In %reboot% query, it was suggested changing the %reboot% times to be shorter or 0, I tried that with no luck. I had this problem under WPI 5.6 and now also under 6 as well. I am running as Administrator. My config.js is attached. I'm getting this on a "brand new" clean XP Pro SP1 install I created just to check that SP2 would install correctly and on an XP Pro SP2 patched up to May'07 install that i just put together to test on. Here are the two error messages I get on the reboot. An error had occurred in the script on this page. Line: 17 Char: 31 Error: Expected ']' Code: 0 URL: file:///D:/WPI/Common/Installer.hta An error had occurred in the script on this page. Line: 462 Char: 2 Error: Object expected Code: 0 URL: file:///D:/WPI/Common/Installer.hta I feel like there might be a solution in zorphnog's the responses to "Script Error" but I don't understand what the problem its supposed to fix is . The help I've gotten already from previous posts has been great. Thanks in advance for any help yall can give me here. Ed config.js
  7. @zorphnog Thanks, I did a global find on all the js files and didn't find a reference to getOSlang() and initially just figured it was cause I don't know jack about js. I added the code you provided to core.js and it worked great. Thanks a bunch! Still wrestling with reboot issues but that's a subject for a different post. Also thanks for the more elegant code. Ed
  8. I want to create a condition to install XP SP2 on only English language machines. I also want to ensure that if someday Microsoft were to release an XP SP3 that this script wouldn't allow the user to try & install SP2 over it if it has been already installed. It would hopefully fail anyway before it went very far by why give the user a chance to waste their time &/or do something stupid. In List of return values for getOSlang() Kelsenellenelvian showed me where to find the list of return values for the getOSlang() (Thank you Kelsenellenelvian) (see %wpipath%\WPIScripts\core.js function CreateLocalArray()) Here is how I think I would write the condition but I'd like to get some feedback from those with more (that would be any) experience then me. getOSver()=="XP" && getSPver()<2 && (getOSlang()=="ENA" || getOSlang()=="ENL" || getOSlang()=="ENC" || getOSlang()=="ENB" || getOSlang()=="ENI" || getOSlang()=="ENJ" || getOSlang()=="ENZ" || getOSlang()=="ENP" || getOSlang()=="ENS" || getOSlang()=="ENT" || getOSlang()=="ENG" || getOSlang()=="ENU" || getOSlang()=="ENW") I think it should work but it strikes me that there has to be a more elegant way to write this. Any suggestions would be greatly appreciated. Ed
  9. Sure looks like you did. And all the ones I needed. Thanks a bunch, especially for the quick reply. Ed
  10. Can anyone give me a list of valid return values for the condition getOSlang()? Microsoft lists the ones they use here List of Locale ID (LCID) Values as Assigned by Microsoft but I wasn't sure if this is the convention used by WPI or not. Any help greatly appreciated, I did a search and didn't find this in the manual or on the forum. Thanks Ed
×
×
  • Create New...