wmiwindows-server-2000wmi-query

WMI Query to get list of Service Packs


Is it possible to find out the service packs that are installed on a Windows 2000 machine using WMI?


Solution

  • There's a suggested way of getting installed software using WMI - although not all software shows up, so you'd have to...

    1) Try it out and see if they appear at all

    2) Adjust the example to filter the results so only service packs show

    strHost = "."
    Const HKLM = &H80000002
    Set objReg = GetObject("winmgmts://" & strHost & _
        "/root/default:StdRegProv")
    Const strBaseKey = _
        "Software\Microsoft\Windows\CurrentVersion\Uninstall\"
    objReg.EnumKey HKLM, strBaseKey, arrSubKeys
    For Each strSubKey In arrSubKeys
        intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, _
            "DisplayName", strValue)
        If intRet <> 0 Then
            intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, _
            "QuietDisplayName", strValue)
        End If
        If (strValue <> "") and (intRet = 0) Then
            WScript.Echo strValue
        End If
    Next