开发者

C# WMI Eventwatcher code stopped working on Windows 7 with security exception

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜