如何使用VBScript列出所有WMI事件类?

时间:2010-10-21 02:38:54

标签: vbscript wmi

使用VBScript,如何列出代表事件的所有WMI类?

提前致谢。

1 个答案:

答案 0 :(得分:3)

您可以将WMI schema query用于从__EVENT继承的类。一个例子是:

Function GetWmiEventClasses(computerName)
    Dim wmiRoot
    Dim eventClasses

    Set wmiRoot = GetObject("winmgmts:\\" & computerName & "\root\cimv2")
    Set eventClasses = wmiRoot.ExecQuery("select * from meta_class where __this isa '__event'") 

    Set GetWmiEventClasses = eventClasses
End Function

<强> USAGE:

Set eventClasses = GetWmiEventClasses("." )

If Not eventClasses Is Nothing Then
    Dim eventClass 

    For Each eventClass In eventClasses
        WScript.Echo eventClass.Path_.Class
    Next 
End If