My colleague encountered a problem the other week with BGInfo reporting “incorrect” version of IE. He had used his package for months with a great success, until when customer requested IE to be upgraded from version 9 to version 11. BGInfo’s built-in variable for IE version returned value that was prefixed with “9.” – and that is true (and known) for both IE10 and IE11. Who knows, that issue might have been already resolved in newer versions of BGInfo – but where’s the fun in that?
While it is OK for IT Professionals to interpret these results, it is not so much acceptable for users in corporate environment where IE version displayed on the desktop would generate unnecessary calls to IT Help Desk and as you can imagine impede resolution of actual incidents.

Values for registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer with IE11 installed.
I haven’t looked into BGInfo’s inner works, but my bet is that the embedded variable looks for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Version registry value. If you have IE10 or IE11 installed, a new value should also be available – svcVersion, that contains desired version of the application without “9.” prefix. This value also may, or may not, exist with previous versions of IE installed. If “svcVersion” does not exist, you can be pretty confident that “Version” value holds correct IE version, as this will mean IE8 or IE9 installed.
So, the easiest way to extract correct registry value is to apply following logic: if “svcVersion” value exists – grab it, otherwise use “Version” value. Since BGInfo does not have built-in means of applying any logic (rather than pointing it to selected registry), we need to resort to good old VBScript to grab our value.
Now, there is a couple of things you need to be aware of before writing your script. First of all, there are some limitations of what objects can be used in VBScript that will be used by BGInfo. Typically I would create a Wscript.Shell object and use RegRead method to get information I need. Unfortunately these can’t be used in this instance, so we need to resort to StdRegProv class instead. Second of all, you need to use ECHO statement followed by result (variable) that you want your script to return. You’ve heard me right – just ECHO statement, not Wscript.Echo. This is a way BGInfo interfaces with your script. Knowing all that – the below code is self-explanatory.
Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." strIEVersion = "" Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\default:StdRegProv") strKeyPath = "Software\Microsoft\Internet Explorer" oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes ' Try to get IE version based on "svcVersion" value For i = 0 To UBound(arrValueNames) If arrValueNames(i) = "svcVersion" Then oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames(i), strIEVersion End If Next ' If IE version was not detected, try to get IE version based on "Version" value If Len(strIEVersion) = 0 Then For i = 0 To UBound(arrValueNames) If arrValueNames(i) = "Version" Then oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames(i), strIEVersion End If Next End If If Len(strIEVersion) = 0 Then strIEVersion = "Unable to determine" End If Echo strIEVersion
Once you have saved your script as .vbs file, you need to create a new custom variable and point it to your script. To do that run BGInfo, click “Custom” button and then “New” button. All you need to do now is name your variable appropriately, select “VB Script file” radio button and point it your file. Your work here is done!

Create custom field using VB Script file in BGInfo.
Discussion
No comments yet.