C# WMI Eventwatcher code stopped working on Windows 7 with security exception
- by Flores
This is code that worked fine on Windows XP for years. User is not local administrator.
WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_ProcessStopTrace");
ConnectionOptions co = new ConnectionOptions();
co.EnablePrivileges = true;
ManagementEventWatcher watcher = new ManagementEventWatcher(new ManagementScope(@"root\cimv2",co), query);
watcher.EventArrived += StopEventArrived;
watcher.Start();
This throws an SecurityException on Windows 7, Access Denied when running as a non admin. On XP this works fine without being admin.
On this link MS states that 'Windows 7: Low-integrity users have read-only permissions for local WMI operations.'. I guess this is the problem.
But I can't find any clue on how to change this.