tags:

views:

24

answers:

1

Using VBScript, how can I list all WMI classes that represent events?

Thanks in advance.

+3  A: 

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 
Garett
+1 thanks very much
Salvador