I have some problems retrieving field values from a WMI query. For example I would like to know the name of the process that has been started:
Dim query As String = "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'" '
watcher = New ManagementEventWatcher(query)
Dim handler As New MyHandler(watcher)
AddHandler watcher.EventArrived, AddressOf handler.Arrived
Public Sub Arrived(ByVal sender As Object, ByVal e As EventArrivedEventArgs)
Try
Dim mbo As ManagementBaseObject = DirectCast(e.NewEvent, ManagementBaseObject)
MsgBox(mbo("Name").value)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Do I have to join tables to do this or what I am I missing?
Dim query As String = "SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'" '
watcher = New ManagementEventWatcher(query)
Dim handler As New MyHandler(watcher)
AddHandler watcher.EventArrived, AddressOf handler.Arrived
Public Sub Arrived(ByVal sender As Object, ByVal e As EventArrivedEventArgs)
Try
Dim mbo As ManagementBaseObject = DirectCast(e.NewEvent, ManagementBaseObject)
MsgBox(mbo("Name").value)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Do I have to join tables to do this or what I am I missing?