本文介绍了Windows 7上的特权提升的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Windows 7上以编程方式获取特权提升. 实际上,我想以编程方式编辑主机文件,但它给路径提供了错误访问被拒绝.
How to get Elevated Privileges on windows 7 programatically. Actually i want to edit hosts file programatically but it gives error Access Denied to path.
推荐答案您不能-不仅如此.如果可以的话,那会破坏目的,不是吗?! 首选方法是为您的应用程序创建一个清单文件集,以设置为requireAdministrator- stackoverflow. com/questions/4084585/how-to-embed-a-manifest-file-at-compile-time-in-visual-studio-2010 [ ^ ] stackoverflow. com/questions/2818179/how-to-force-my-net-app-to-run-as-administrator-on-windows-7 [ ^ ] 否则,您仍然需要执行某种模拟,这将导致一个对话框来检索执行模拟所用的用户名\密码凭据,这实际上就是您对清单所做的事情. You can''t - not just like that. If you could, it would kind of defeat the purpose wouldn''t it?! The preferred way is to create a manifest file set to requireAdministrator for your application - stackoverflow/questions/4084585/how-to-embed-a-manifest-file-at-compile-time-in-visual-studio-2010[^] stackoverflow/questions/2818179/how-to-force-my-net-app-to-run-as-administrator-on-windows-7[^] Otherwise, you''d still need to perform some sort of imperstonation, which would result in a dialog to retrieve user name \ password credentials with which to perform the impersonation, which is essentially what you''re doing with the manifest.
更多推荐
Windows 7上的特权提升
发布评论