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 C开发者_开发知识库onnectionOptions();
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.
Workaround:
I ended up creating a windows service that runs in 'local system' context, and commanding this service by WCF.
精彩评论