1

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

Thanks in advance.

Helen
  • 87,344
  • 17
  • 243
  • 314
Salvador
  • 16,132
  • 33
  • 143
  • 245
  • BTW, here's the same question, but asking for a C# solution: [List of WMIEvent classes](http://stackoverflow.com/questions/1043220/list-of-wmievent-classes) – Helen Oct 23 '10 at 09:40

1 Answers1

3

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
  • 16,632
  • 5
  • 55
  • 63