myselfidem Posted December 21, 2013 Posted December 21, 2013 (edited) @KelsTested the link at first page and works fine! I sent 100 Dollars... and could you give me one license for WPI ?I have sent using a MasterCard from a friend of mine (Jean-Pierre).Thank you very much and have a nice Merry Christmas and God bless you.Regards Edited December 21, 2013 by myselfidem
Kelsenellenelvian Posted December 21, 2013 Author Posted December 21, 2013 Thank you so much! Of course you can have a license. Pm me your real life info and email address and I will send it to you tonight.
bphlpt Posted December 22, 2013 Posted December 22, 2013 (edited) ... but now we need more code about function getOSver() inside wmi.jsThe problem you are running into is in your "if" statements. You are executing all of them one after another. So if you find "8.1", of course you are going to find "8" in the next statement so it will get set to "Win8". Overall, your searches for "8.1", "8", and "2008" can potentially interfere with each other.There are two basic ways to handle this, and whichever way you do it will require a slightly different order of the "if" statements to get the correct result.1) If you are going to execute all of the "if" statements, you need to start with the most general search and get more specific as you go. In this case that just means switching the order of the first two "if" statements: if (Caption.indexOf("8") != -1) szOSVerCache="Win8"; if (Caption.indexOf("8.1") != -1) szOSVerCache="Win8.1"; if (Caption.indexOf("7") != -1) szOSVerCache="Win7"; if (Caption.indexOf("2008") != -1) szOSVerCache="08"; if (Caption.indexOf("Vista") != -1) szOSVerCache="Vista"; if (Caption.indexOf("2003") != -1) szOSVerCache="03"; if (Caption.indexOf("XP") != -1) szOSVerCache="XP"; if (Caption.indexOf("2000") != -1) szOSVerCache="2K"; 2) You could also only execute the "if" statements until you find a match then quit checking. In that case you need to start with the most specific search and get get more general as you go. This would mean moving your test for "2008" up before your search for "8", and then adding a "break" statement as part of every "if": findOS: { if (Caption.indexOf("8.1") != -1) { szOSVerCache="Win8.1"; break findOS; } if (Caption.indexOf("2008") != -1) { szOSVerCache="08"; break findOS; } if (Caption.indexOf("8") != -1) { szOSVerCache="Win8"; break findOS; } if (Caption.indexOf("7") != -1) { szOSVerCache="Win7"; break findOS; } if (Caption.indexOf("Vista") != -1) { szOSVerCache="Vista"; break findOS; } if (Caption.indexOf("2003") != -1) { szOSVerCache="03"; break findOS; } if (Caption.indexOf("XP") != -1) { szOSVerCache="XP"; break findOS; } if (Caption.indexOf("2000") != -1) { szOSVerCache="2K"; break findOS; } }While I like that concept, since it seems pointless to keep checking once you found what you are looking for, I like it even better if I make it more compact, flexible and expandable through the use of arrays: var OSoptions = ["8.1", "2008", "8", "7", "Vista", "2003", "XP", "2000"] var OSdesignation = ["Win8.1", "08", "Win8", "Win7", "Vista", "03", "XP", "2K"] for (var i=0, len=OSoptions.length; i<len; i++) { if (Caption.indexOf(OSoptions[i]) != -1) { szOSVerCache=OSdesignation[i]; break; } } In either case, to further shorten the code, and this is more of a programming style preference, unless the values that are set here for objWMIService, colItems, objItem, and enumItems are used elsewhere, and I don't THINK they are, but they are globals so someone needs to confirm this, then Caption can be set in one line by: var Caption=new Enumerator(GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly)).item().Caption; So, to me, your two choices are either:function getOSver() { position="wmi.js"; whatfunc="getOSver()"; if (szOSVerCache==NOT_FOUND) // this function is called often - get it once and cache the result { try { var Caption=new Enumerator(GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly)).item().Caption; if (Caption.indexOf("8") != -1) szOSVerCache="Win8"; if (Caption.indexOf("8.1") != -1) szOSVerCache="Win8.1"; if (Caption.indexOf("7") != -1) szOSVerCache="Win7"; if (Caption.indexOf("2008") != -1) szOSVerCache="08"; if (Caption.indexOf("Vista") != -1) szOSVerCache="Vista"; if (Caption.indexOf("2003") != -1) szOSVerCache="03"; if (Caption.indexOf("XP") != -1) szOSVerCache="XP"; if (Caption.indexOf("2000") != -1) szOSVerCache="2K"; } catch(ex) { } } return szOSVerCache; }or:function getOSver() { position="wmi.js"; whatfunc="getOSver()"; if (szOSVerCache==NOT_FOUND) // this function is called often - get it once and cache the result { try { var Caption=new Enumerator(GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly)).item().Caption; var OSoptions = ["8.1", "2008", "8", "7", "Vista", "2003", "XP", "2000"] var OSdesignation = ["Win8.1", "08", "Win8", "Win7", "Vista", "03", "XP", "2K"] for (var i=0, len=OSoptions.length; i<len; i++) { if (Caption.indexOf(OSoptions[i]) != -1) { szOSVerCache=OSdesignation[i]; break; } } } catch(ex) { } } return szOSVerCache; }and personally I prefer the last one. Since they are constants, you may also define the OSoptions and OSdesignation arrays in globals.js to make getOSver() even shorter, but I think it probably makes more sense to leave it here for better readability, unless you could use those arrays elsewhere in addition to here.Cheers and Regards Edited December 22, 2013 by bphlpt
bphlpt Posted December 22, 2013 Posted December 22, 2013 (edited) By the way, when looking at MS for code examples, when they check objWMIService, they seem to do it like this:objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\" + "." + "\\root\\CIMV2");rather than like this:objWMIService=GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2");They both seem to work in my very simple tests. Does anyone know if there is any real difference? Just curious.Cheers and Regards Edited December 22, 2013 by bphlpt
Francesco Posted December 22, 2013 Posted December 22, 2013 (edited) if (Caption.indexOf("Windows 2012") != -1) szOSVerCache="12"; else if (Caption.indexOf("Windows 8") != -1) szOSVerCache="Win8"; else if (Caption.indexOf("Windows 7") != -1) szOSVerCache="Win7"; else if (Caption.indexOf("2008") != -1) szOSVerCache="08"; else if (Caption.indexOf("Vista") != -1) szOSVerCache="Vista"; else if (Caption.indexOf("2003") != -1) szOSVerCache="03"; else if (Caption.indexOf("XP") != -1) szOSVerCache="XP"; else if (Caption.indexOf("2000") != -1) szOSVerCache="2K"; if (szOSVerCache=="08") szEditionIDCache=getOSsku(OSSKU); else if (szOSVerCache=="Vista") szEditionIDCache=getOSsku(OSSKU); else if (szOSVerCache=="03") { if (Caption.indexOf("Standard") != -1) szEditionIDCache="Standard Edition"; else if (Caption.indexOf("Enterprise") != -1) szEditionIDCache="Enterprise Edition"; else if (Caption.indexOf("Web") != -1) szEditionIDCache="Web Edition"; else if (Caption.indexOf("Datacenter") != -1) szEditionIDCache="Datacenter Edition"; else if (Caption.indexOf("Itanium") != -1) szEditionIDCache="Itanium Edition"; } else if (szOSVerCache=="XP") { if (Caption.indexOf("Home") != -1) szEditionIDCache="Home Edition"; else if (Caption.indexOf("Professional") != -1) szEditionIDCache="Professional Edition"; } else if (szOSVerCache=="2K") { if (Caption.indexOf("Professional") != -1) szEditionIDCache="Professional Edition"; else if (Caption.indexOf("2000 Server") != -1) szEditionIDCache="Server Edition"; else if (Caption.indexOf("2000 Advanced Server") != -1) szEditionIDCache="Advanced Server Edition"; else if (Caption.indexOf("Datacenter") != -1) szEditionIDCache="Datacenter Edition"; }problem solved? Edited December 22, 2013 by Francesco
myselfidem Posted December 22, 2013 Posted December 22, 2013 (edited) Many thanks Francesco and bphlpt !Tested and works like this:Inside wmi.js changing to:function getOSver() { position="wmi.js"; whatfunc="getOSver()"; if (szOSVerCache==NOT_FOUND) // this function is called often - get it once and cache the result { try { objWMIService=GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2"); colItems=objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); enumItems=new Enumerator(colItems); objItem=enumItems.item(); var Caption=objItem.Caption; if (Caption.indexOf("8") != -1) szOSVerCache="Win8"; if (Caption.indexOf("8.1") != -1) szOSVerCache="Win8.1"; if (Caption.indexOf("7") != -1) szOSVerCache="Win7"; if (Caption.indexOf("2008") != -1) szOSVerCache="08"; if (Caption.indexOf("Vista") != -1) szOSVerCache="Vista"; if (Caption.indexOf("2012") != -1) szOSVerCache="12"; if (Caption.indexOf("2003") != -1) szOSVerCache="03"; if (Caption.indexOf("XP") != -1) szOSVerCache="XP"; if (Caption.indexOf("2000") != -1) szOSVerCache="2K"; } catch(ex) { } } return szOSVerCache; }function getOSeditionID(){ position = "wmi.js"; whatfunc = "getOSeditionID()"; var Caption, OSSKU; if (szEditionIDCache == NOT_FOUND) // this function is called often - get it once and cache the result { try { objWMIService = GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2"); colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); enumItems = new Enumerator(colItems); objItem = enumItems.item(); Caption = objItem.Caption; OSSKU = objItem.OperatingSystemSKU; if (szOSVerCache == "Win8.1") szEditionIDCache = getOSsku(OSSKU); if (szOSVerCache == "Win8") szEditionIDCache = getOSsku(OSSKU); if (szOSVerCache == "Win7") szEditionIDCache = getOSsku(OSSKU); if (szOSVerCache == "08") szEditionIDCache = getOSsku(OSSKU); if (szOSVerCache == "Vista") szEditionIDCache = getOSsku(OSSKU); if (szOSVerCache == "12") szEditionIDCache = objItem.Caption; if (szOSVerCache == "03") szEditionIDCache = objItem.Caption; if (szOSVerCache == "XP") szEditionIDCache = objItem.Caption; if (szOSVerCache == "2K") szEditionIDCache = objItem.Caption; } catch(ex) { ; } } return szEditionIDCache;}We need also add inside configwizard.js (from line 776)case 'cmd_cond_operatingsystem': HandleCommandsSelectionMenu("{OS=Win8.1 || Win8 || Win7 || Vista || XP || 2K} "); break;Inside installer.js we can add (on line 1400):if (getOSver() == "Win7" || getOSver() == "Win8" || getOSver() == "Win8.1")Problem solved!Regards*Edit: post updated Edited December 22, 2013 by myselfidem
bphlpt Posted December 22, 2013 Posted December 22, 2013 (edited) I noticed that Francesco included 2012 in his code for getOSver(), while you did not. Was that on purpose? I also noticed that he specifically called out "Home Edition" and "Professional Edition" in his code for getOSeditionID(), while you just used the Caption. Was that on purpose? You also did not include 2012 in getOSeditionID(). Was that on purpose?It's a shame that OperatingSystemSKU and getOSsku() aren't more complete and match the way you want szEditionIDCache to read. Could they be extended so that was so? If they were, then getOSeditionID() would essentially be reduced to szEditionIDCache = getOSsku(objItem.OperatingSystemSKU).I did like Francesco's use of "if ... else if" statements, which accomplish the same purpose of my "break" suggestion, and I suppose are a little easier to read.Assuming that you wanted to recognize 2012 in both getOSver() and getOSeditionID(), and you meant to use Francesco's code re XP in getOSeditionID(), and OperatingSystemSKU and getOSsku() are able to be used for 2012 in getOSeditionID(), then this also includes Francesco's "if ... else if" statements:function getOSver3() { position="wmi.js"; whatfunc="getOSver()"; if (szOSVerCache==NOT_FOUND) // this function is called often - get it once and cache the result { try { var Caption=new Enumerator(GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly)).item().Caption; if (Caption.indexOf("8.1") != -1) szOSVerCache="Win8.1"; else if (Caption.indexOf("2008") != -1) szOSVerCache="08"; else if (Caption.indexOf("8") != -1) szOSVerCache="Win8"; else if (Caption.indexOf("7") != -1) szOSVerCache="Win7"; else if (Caption.indexOf("Vista") != -1) szOSVerCache="Vista"; else if (Caption.indexOf("2012") != -1) szOSVerCache="12"; else if (Caption.indexOf("2003") != -1) szOSVerCache="03"; else if (Caption.indexOf("XP") != -1) szOSVerCache="XP"; else if (Caption.indexOf("2000") != -1) szOSVerCache="2K"; } catch(ex) { } } return szOSVerCache; } function getOSeditionID(){ position = "wmi.js"; whatfunc = "getOSeditionID()"; if (szEditionIDCache == NOT_FOUND) // this function is called often - get it once and cache the result { try { objItem = new Enumerator(GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly)).item(); var Caption = objItem.Caption; var OSSKU = objItem.OperatingSystemSKU; if (szOSVerCache == "Win8.1") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "Win8") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "Win7") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "08") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "Vista") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "12") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "03") { if (Caption.indexOf("Standard") != - 1) szEditionIDCache = "Standard Edition"; else if (Caption.indexOf("Enterprise") != - 1) szEditionIDCache = "Enterprise Edition"; else if (Caption.indexOf("Web") != - 1) szEditionIDCache = "Web Edition"; else if (Caption.indexOf("Datacenter") != - 1) szEditionIDCache = "Datacenter Edition"; else if (Caption.indexOf("Itanium") != - 1) szEditionIDCache = "Itanium Edition"; } else if (szOSVerCache == "XP") { if (Caption.indexOf("Home") != -1) szEditionIDCache="Home Edition"; else if (Caption.indexOf("Professional") != -1) szEditionIDCache="Professional Edition"; } else if (szOSVerCache == "2K") { if (Caption.indexOf("Professional") != - 1) szEditionIDCache = "Professsional Edition"; else if (Caption.indexOf("2000 Server") != - 1) szEditionIDCache = "Server Edition"; else if (Caption.indexOf("2000 Advanced Server") != - 1) szEditionIDCache = "Advanced Server Edition"; else if (Caption.indexOf("Datacenter") != - 1) szEditionIDCache = "Datacenter Edition"; } } catch(ex) { ; } } return szEditionIDCache;} I was tempted to replace: if (szOSVerCache == "Win8.1") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "Win8") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "Win7") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "08") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "Vista") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "12") szEditionIDCache = getOSsku(OSSKU); else if (szOSVerCache == "03") ... with: szEditionIDCache = getOSsku(OSSKU); if (szOSVerCache == "03") ...but didn't on the off chance that szOSVerCache was not set correctly.getOSver() and getOSeditionID() could really be combined into a single function and the overall logic would then be easier. Like this:function getOSver() { position="wmi.js"; whatfunc="getOSver()"; if (szOSVerCache==NOT_FOUND) setOSverOSedID(); // this function is called often - get it once and cache the result return szOSVerCache; }function getOSeditionID(){ position = "wmi.js"; whatfunc = "getOSeditionID()"; if (szEditionIDCache==NOT_FOUND) setOSverOSedID(); // this function is called often - get it once and cache the result return szEditionIDCache;}function setOSverOSedID() { position="wmi.js"; whatfunc="setOSverOSedID()"; try { objItem = new Enumerator(GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly)).item(); var Caption = objItem.Caption; var OSSKU = objItem.OperatingSystemSKU; if (Caption.indexOf("8.1") != -1) { szOSVerCache="Win8.1"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("2008") != -1) { szOSVerCache="08"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("8") != -1) { szOSVerCache="Win8"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("7") != -1) { szOSVerCache="Win7"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("Vista") != -1) { szOSVerCache="Vista"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("2012") != -1) { szOSVerCache="12"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("2003") != -1) { szOSVerCache="03"; if (Caption.indexOf("Standard") != - 1) szEditionIDCache = "Standard Edition"; else if (Caption.indexOf("Enterprise") != - 1) szEditionIDCache = "Enterprise Edition"; else if (Caption.indexOf("Web") != - 1) szEditionIDCache = "Web Edition"; else if (Caption.indexOf("Datacenter") != - 1) szEditionIDCache = "Datacenter Edition"; else if (Caption.indexOf("Itanium") != - 1) szEditionIDCache = "Itanium Edition"; } else if (Caption.indexOf("XP") != -1) { szOSVerCache="XP"; if (Caption.indexOf("Home") != -1) szEditionIDCache="Home Edition"; else if (Caption.indexOf("Professional") != -1) szEditionIDCache="Professional Edition"; } else if (Caption.indexOf("2000") != -1) { szOSVerCache="2K"; if (Caption.indexOf("Professional") != - 1) szEditionIDCache = "Professsional Edition"; else if (Caption.indexOf("2000 Server") != - 1) szEditionIDCache = "Server Edition"; else if (Caption.indexOf("2000 Advanced Server") != - 1) szEditionIDCache = "Advanced Server Edition"; else if (Caption.indexOf("Datacenter") != - 1) szEditionIDCache = "Datacenter Edition"; } } catch(ex) { ; } }Edit or eliminate 2012 as appropriate. And this might could be simplified further with some work on getOSsku(). Just a suggestion.Cheers and Regards Edited December 22, 2013 by bphlpt
myselfidem Posted December 22, 2013 Posted December 22, 2013 (edited) I updated my last post (post #52) adding Windows Server 2012 and adding some of your ideas.About szEditionIDCache doesn't work with Windows Edition other than English ! There is no value for Windows Edition Multilanguage (French, German, Italian, etc.).It is the reason I used: if (szOSVerCache == "12") szEditionIDCache = objItem.Caption; if (szOSVerCache == "03") szEditionIDCache = objItem.Caption; if (szOSVerCache == "XP") szEditionIDCache = objItem.Caption; if (szOSVerCache == "2K") szEditionIDCache = objItem.Caption; Help about OSSKU Edition:http://msdn.microsoft.com/en-us/library/windows/desktop/ms724358%28v=vs.85%29.aspxRegards*Edit: tested using else if statement and doesn't work !! Edited December 22, 2013 by myselfidem
myselfidem Posted December 22, 2013 Posted December 22, 2013 (edited) @bphlptYou shared 2 codes (post #50): the first is VBS and the second JavaScript code*Edit: The button doesn't work for me to quote your post Edited December 22, 2013 by myselfidem
myselfidem Posted December 22, 2013 Posted December 22, 2013 (edited) Inside aboutwpitemplate_license.htm, please change the line 19 to:<a target="_blank" href="http://www.msfn.org/board/forum/93-windows-post-install-wizard-wpi/">MSFN\WPIW Forum Section.</a> (www.msfn.org)<br>Now, the link works.Inside aboutwpitemplate_projectteam.htm on line 20, change to:<a target="_blank" href="http://www.msfn.org/board/user/273131-myselfidem/">myselfidem</a><br>Thanks and regards Edited December 22, 2013 by myselfidem
bphlpt Posted December 23, 2013 Posted December 23, 2013 (edited) You shared 2 codes (post #50): the first is VBS and the second JavaScript code Thanks. I thought it might have been something like that.About szEditionIDCache doesn't work with Windows Edition other than English ! There is no value for Windows Edition Multilanguage (French, German, Italian, etc.).It is the reason I used: if (szOSVerCache == "12") szEditionIDCache = objItem.Caption; if (szOSVerCache == "03") szEditionIDCache = objItem.Caption; if (szOSVerCache == "XP") szEditionIDCache = objItem.Caption; if (szOSVerCache == "2K") szEditionIDCache = objItem.Caption; Help about OSSKU Edition:http://msdn.microsoft.com/en-us/library/windows/desktop/ms724358(v=vs.85).aspxSince the conversion from the OperatingSystemSKU number to the "friendly" word version is totally under the control of getOSsku(), or getOSeditionID(), I would think that translations could be provided by the translators of WPI, so that all languages that WPI is available in could have the messages in their language. Isn't that the purpose of the translated versions? For a language that hasn't had a translation provided, everything would be in English. Isn't that the way it's supposed to work? Now if the OperatingSystemSKU number isn't always accurate, then that's a whole different problem. I guess I just don't understand why it is able to be used for some OS versions and not for others.I updated my last post (post #52) adding Windows Server 2012 and adding some of your ideas.*Edit: tested using else if statement and doesn't work !!With your changes it's even shorter now. Paste this into wmi.js. ( Comment out or rename the existing getOSver() and getOSeditionID(). ) It works for me. If it still doesn't for you, please tell me exactly what it does or what error message you get. There is no reason it shouldn't work.function getOSver() { position="wmi.js"; whatfunc="getOSver()"; if (szOSVerCache==NOT_FOUND) setOSverOSedID(); // this function is called often - get it once and cache the result return szOSVerCache; }function getOSeditionID(){ position = "wmi.js"; whatfunc = "getOSeditionID()"; if (szEditionIDCache==NOT_FOUND) setOSverOSedID(); // this function is called often - get it once and cache the result return szEditionIDCache;}function setOSverOSedID() { position="wmi.js"; whatfunc="setOSverOSedID()"; try { objItem = new Enumerator(GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly)).item(); var Caption = objItem.Caption; var OSSKU = objItem.OperatingSystemSKU; if (Caption.indexOf("8.1") != -1) { szOSVerCache = "Win8.1"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("2008") != -1) { szOSVerCache = "08"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("8") != -1) { szOSVerCache = "Win8"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("7") != -1) { szOSVerCache = "Win7"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("Vista") != -1) { szOSVerCache = "Vista"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("2012") != -1) { szOSVerCache = "12"; szEditionIDCache = Caption; } else if (Caption.indexOf("2003") != -1) { szOSVerCache = "03"; szEditionIDCache = Caption; } else if (Caption.indexOf("XP") != -1) { szOSVerCache = "XP"; szEditionIDCache = Caption; } else if (Caption.indexOf("2000") != -1) { szOSVerCache = "2K"; szEditionIDCache = Caption; } } catch(ex) { ; } }EDIT: Sorry, typo. If you tried it before now, try it again.Cheers and Regards Edited December 23, 2013 by bphlpt
myselfidem Posted December 23, 2013 Posted December 23, 2013 (edited) Many thanks bphlpt.Your last example works fine ! I removed only unwanted spaces:function getOSver() { position = "wmi.js"; whatfunc = "getOSver()"; if (szOSVerCache==NOT_FOUND) setOSverOSedID(); // this function is called often - get it once and cache the result return szOSVerCache; }function getOSeditionID(){ position = "wmi.js"; whatfunc = "getOSeditionID()"; if (szEditionIDCache==NOT_FOUND) setOSverOSedID(); // this function is called often - get it once and cache the result return szEditionIDCache;}function setOSverOSedID() { position = "wmi.js"; whatfunc = "setOSverOSedID()"; try { objItem = new Enumerator(GetObject("winmgmts:\\\\" + "." + "\\root\\CIMV2").ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly)).item(); var Caption = objItem.Caption; var OSSKU = objItem.OperatingSystemSKU; if (Caption.indexOf("8.1") != -1) { szOSVerCache = "Win8.1"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("2008") != -1) { szOSVerCache = "08"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("8") != -1) { szOSVerCache = "Win8"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("7") != -1) { szOSVerCache = "Win7"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("Vista") != -1) { szOSVerCache = "Vista"; szEditionIDCache = getOSsku(OSSKU); } else if (Caption.indexOf("2012") != -1) { szOSVerCache = "12"; szEditionIDCache = Caption; } else if (Caption.indexOf("2003") != -1) { szOSVerCache = "03"; szEditionIDCache = Caption; } else if (Caption.indexOf("XP") != -1) { szOSVerCache = "XP"; szEditionIDCache = Caption; } else if (Caption.indexOf("2000") != -1) { szOSVerCache = "2K"; szEditionIDCache = Caption; } } catch(ex) { ; } }Regards Edited December 23, 2013 by myselfidem
bphlpt Posted December 23, 2013 Posted December 23, 2013 Many thanks bphlpt. Your last example works fine ! I removed only unwanted spaces: Glad to hear it. LOL I thought the extra spaces made it more readable Cheers and Regards
myselfidem Posted December 23, 2013 Posted December 23, 2013 @bphlpt and Francesco,Many thanks for your help. Have a Merry Christmas and God bless you !
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now