是否可以找到使用WMI安装在Windows 2000计算机上的Service Pack?
答案 0 :(得分:2)
有一种建议使用WMI安装软件的方法 - 尽管并非所有软件都显示出来,所以你必须......
1)尝试一下,看看它们是否出现
2)调整示例以过滤结果,只显示服务包
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
答案 1 :(得分:0)
是的,wmi类Win32_OperatingSystem包含所有这些信息。我可以通过使用powershell检查我的本地计算机来验证此信息:
PS c:\> get-wmiobject win32_operatingsystem | `
select BuildNumber, ServicePackMajorVersion, `
ServicePackMinorVersion | format-table -auto
BuildNumber ServicePackMajorVersion ServicePackMinorVersion
----------- ----------------------- -----------------------
7100 0 0
注意:Powershell仅在XP或更高版本上运行,但您可以通过将-Computer参数传递给get-wmiobject来检查远程系统。
答案 2 :(得分:0)
来自Hey, Scripting Guy!系列的VBScript示例:
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