R
Rob
Hello.
I'm attempting to write a VB.NET application to monitor events they are
written to the Windows event logs.
I have the following code, but it fails at the Start method, throwing an
'Access Denied' exception. This is being run under the administrator
account:
'Initialize an event watcher object with this query
Dim watcher As New ManagementEventWatcher(New
WqlEventQuery("__InstanceCreationEvent", "TargetInstance ISA
'Win32_NTLogEvent'"))
'Set up a handler for incoming events
Dim handler As New MyHandler()
AddHandler watcher.EventArrived, AddressOf handler.Arrived
'Start watching for events
watcher.Start() 'CODE FAILS HERE
'loop to wait for an event to arrive.
While Not handler.IsArrived
Console.Write("0")
System.Threading.Thread.Sleep(1000)
End While
'only wait for one event, so stop watching
watcher.Stop()
Please help!
I'm attempting to write a VB.NET application to monitor events they are
written to the Windows event logs.
I have the following code, but it fails at the Start method, throwing an
'Access Denied' exception. This is being run under the administrator
account:
'Initialize an event watcher object with this query
Dim watcher As New ManagementEventWatcher(New
WqlEventQuery("__InstanceCreationEvent", "TargetInstance ISA
'Win32_NTLogEvent'"))
'Set up a handler for incoming events
Dim handler As New MyHandler()
AddHandler watcher.EventArrived, AddressOf handler.Arrived
'Start watching for events
watcher.Start() 'CODE FAILS HERE
'loop to wait for an event to arrive.
While Not handler.IsArrived
Console.Write("0")
System.Threading.Thread.Sleep(1000)
End While
'only wait for one event, so stop watching
watcher.Stop()
Please help!