2009-06-12 59 views

回答

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 
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或更高,但你可以通過傳遞 - 電腦參數來獲取-WmiObject可以查看遠程系統。

0

一個VBScript例如從Hey, Scripting Guy!系列:

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