Browse DevX
Sign up for e-mail newsletters from DevX


Comparing Computer Information with WMI, Part II-3 : Page 3

Fixing the Inevitable
If you've worked extensively with Microsoft operating systems, you are familiar with Service Packs, and their smaller cousins, the Quick Engineering Fixes (QEF). Even with automatic notifications, it's hard enough to keep up with all the current QEFs for your own local computer. Determining whether all the computers on your network have the correct QEFs installed is an even more daunting task.

Figure 3. The Fix Is In: If you swim in Microsoft's ocean, you need to keep up with not only the current service packs, but the post service pack quick-fixes. A simple registry call (run under WMI) will get you this information.
WMI has an object that exposes the QEFs installed on a computer—Win32_QuickFixEngineering. However, this method has at least two problems that I'm aware of. First, on a pre-SP3 version of W2K, it can cause the WinMgmt process to hang. This bug is fixed in a post SP2 QEF, and in SP3 for W2K. Also, the WMI object seems to incorrectly parse some of the QEF information (which is located in the registry), and provides duplicate data for many of the QEFs. I have provided the WMI version of the program with the GetHotFixData function. For safety, I've written a private method GetOS that uses the public GetOsData to determine if you are running W2K and if you are at SP3 or above (see the code below). If you fail these two tests, the function returns False so you can abort the call to WMI (if you don't abort the call, it might lock up the computer with 100% processor activity for WinMgmt).

Private Function GetOS_
(ByVal xi_sWbemServices As SWbemServices) As Variant
Dim vntTmp                          As Variant
Dim vntRtn                          As Variant
ReDim vntRtn(1 To 2) As Variant
vntTmp = GetOsData(xi_sWbemServices)
If Left$(vntTmp(1, 13), 4) = "5.0." Then
   If CLng(vntTmp(1, 25)) >= 3 Then
      vntRtn(1) = True
      vntRtn(2) = vbNullString
      vntRtn(1) = False
      vntRtn(2) = "If you are running W2K, _
	  you must have at least SP3 to run this " & _
	"method. You are running SP " & vntTmp(1, 25)
   End If
   vntRtn(1) = True
   vntRtn(2) = vbNullString
End If
GetOS = vntRtn
End Function

I've also provided GetHotFixData2, which queries the registry directly (much as in the GetInstalledSoftwareData2). You can see the results in Figure 3. The code is very similar to the registry code for the installed software (download here).

The ways you can extend comparisons between two computers with WMI are extensive. I may revisit this program sometime in the future, but if you have any suggestions, please let me know.

L.J. Johnson is the owner of Slightly Tilted Software in Dallas, Texas. He has been programming in Visual Basic since 1.0 and is a Microsoft Most Valuable Professional (MVP).
Thanks for your registration, follow us on our social networks to keep up-to-date