开发者

How to list all WMI event classes using VBScript?

Using VBScript, how can I list all WMI 开发者_C百科classes that represent events?

Thanks in advance.


You can use WMI schema query for classes that inherit from __EVENT. An example would be:

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 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜