Is it possible to find out the service packs that are installed on a Windows 2000 machine using WMI?
Asked
Active
Viewed 2,186 times
3 Answers
2
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

Fenton
- 241,084
- 71
- 387
- 401
0
Yes, the wmi class Win32_OperatingSystem contains all of this information. I can see verify this information by using powershell to check my local machine:
PS c:\> get-wmiobject win32_operatingsystem | `
select BuildNumber, ServicePackMajorVersion, `
ServicePackMinorVersion | format-table -auto
BuildNumber ServicePackMajorVersion ServicePackMinorVersion
----------- ----------------------- -----------------------
7100 0 0
Note: Powershell only runs on XP or higher, but you can check remote systems by passing a -Computer parameter to get-wmiobject.

x0n
- 51,312
- 7
- 89
- 111
0
A VBScript example from Hey, Scripting Guy! series:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
Wscript.Echo objOperatingSystem.ServicePackMajorVersion _
& "." & objOperatingSystem.ServicePackMinorVersion
Next

Helen
- 87,344
- 17
- 243
- 314