简体   繁体   中英

Addressing “Access Denied” Exception with WMI Calls

I'm getting an exception with a message of "Access Denied" when executing against a WMI request. Some WMI requests appear to require higher security privileges than others. Ultimately my goal is to monitor process launches within the system and log. Regardless if there is a better approach, its now become a vendetta in getting this WMI approach to work.

I've attempted the code at Security Tools -> WMI Programming Using C#.Net and still receive the exception. If you copy the code found in the blog entry you can reproduce my issue.

Another post on a similar topic can be found at link text but again, try the code and you'll the see the same security exception.

How do I permit my code to execute these WMI requests?

I'm running on Windows 7 Pro and VS 2010 in a new C# command line project.

Edit: Choosing "Run As Administrator" for the VS2010 instance and then executing the code works. How do I automate this so a user doesn't have to manually elevate the privilege?

Some of these WMI calls may need admin privileges. did you try right clicking your .exe file and selecting "Run As Administrator"?

Add a manifest to your program so that it always runs with Admin privileges. Here is another link which is more to the point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM