Windows 7上的特权提升 [英] Elevated Privileges on Windows 7

查看:129
本文介绍了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-

http://stackoverflow. com/questions/4084585/how-to-embed-a-manifest-file-at-compile-time-in-visual-studio-2010 [ ^ ]

http://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 -

http://stackoverflow.com/questions/4084585/how-to-embed-a-manifest-file-at-compile-time-in-visual-studio-2010[^]

http://stackoverflow.com/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上的特权提升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆