mario28639496
mario28639496

Reputation: 11

How to subscribe to Event from Microsoft-Windows-NetworkProfile/Operational using WMI

I am trying to subscribe to Event 10000 in the Microsoft-Windows-NetworkProfile/Operational log using WMI, similar to how I am subscribing to events in the "Windows Logs/Application" log. However, the OnWmiEventArrived method is not being triggered when this event occurs, even though it is logged in the Event Viewer. The same code works for events logged under "Windows Logs/Application".

string query = @"
SELECT * FROM __InstanceCreationEvent WITHIN 1 
WHERE TargetInstance ISA 'Win32_NTLogEvent' 
AND TargetInstance.EventCode = '10000'";

ManagementEventWatcher generalWatcher = new ManagementEventWatcher(query);
generalWatcher.EventArrived += new EventArrivedEventHandler(OnWmiEventArrived);
generalWatcher.Start();

The above code works for events in the "Windows Logs/Application" log, but it does not seem to work for events in Microsoft-Windows-NetworkProfile/Operational. Is there a way to subscribe to events in a different log such as Microsoft-Windows-NetworkProfile/Operational?

Upvotes: 1

Views: 47

Answers (0)

Related Questions