解决“访问被拒绝”的问题WMI 调用异常
针对 WMI 请求执行时,我收到异常消息“访问被拒绝”。某些 WMI 请求似乎比其他请求需要更高的安全权限。最终我的目标是监视系统内的进程启动并记录。不管是否有更好的方法,它现在都成为让这种 WMI 方法发挥作用的宿怨。
我尝试了 Security 中的代码工具->使用 C#.Net 进行 WMI 编程,但仍然收到异常。如果您复制博客条目中的代码,您可以重现我的问题。
关于类似主题的另一篇文章可以在链接文本中找到但再次尝试该代码,您将看到相同的安全异常。
如何允许我的代码执行这些 WMI 请求?
我在新的 C# 命令行项目中运行 Windows 7 Pro 和 VS 2010。
编辑: 为 VS2010 实例选择“以管理员身份运行”,然后执行代码即可。如何自动执行此操作,以便用户不必手动提升权限?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
其中一些 WMI 调用可能需要管理员权限。您是否尝试右键单击 .exe 文件并选择“以管理员身份运行”?
向您的程序添加清单,以便它始终以管理员权限运行。 这里是另一个更切题的链接。
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.
http://social.technet。 microsoft.com/Forums/en/winserverhyperv/thread/2a7e8ba9-2a9e-46c2-8233-3eb65cfd16cc
这将帮助你..
http://social.technet.microsoft.com/Forums/en/winserverhyperv/thread/2a7e8ba9-2a9e-46c2-8233-3eb65cfd16cc
This will help u..