在 vb.net 中以管理员身份运行程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20165879/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run Program as Administrator in vb.net
提问by user3024698
I am programming with vb.net . I have a program which needs Administrator Privileges
我正在用 vb.net 编程。我有一个需要管理员权限的程序
I want: If program started then a Prompt Show (UAC(User Account Control)) shows that it have to tun as administrator. Is it possible?
我想要:如果程序启动,则提示显示(UAC(用户帐户控制))显示它必须以管理员身份进行调整。是否可以?
回答by BaeFell
You can do the following to make sure the program has admin permissions:
您可以执行以下操作以确保程序具有管理员权限:
You can edit the UAC Settings (in VB 2008), which is located in the Project Settings. Look for the line that says
您可以编辑位于项目设置中的 UAC 设置(在 VB 2008 中)。寻找说的那一行
Change level="asInvoker"
to:
更改level="asInvoker"
为:
level="asInvoker"
(normal account - default)
level="asInvoker"
(普通账户 - 默认)
level="requireAdministrator
(require administrator - What you need... but could be next one)
level="requireAdministrator
(需要管理员 - 你需要什么......但可能是下一个)
level="highestAvailable"
(if anything is higher then administrator, require that)
level="highestAvailable"
(如果有什么高于管理员,则要求)
Hope it helps :)
希望能帮助到你 :)
-nfell2009
-nfell2009
回答by user2562950
None of the project settings suggestions worked for me in Windows 10 64 bit. I changed to Release, I replaced "asInvoker" line with "requireAdministrator" line and still was getting Access Denied Exceptions. The only way to run thru VS2013 is to run the environment off the bat AS AN ADMINISTRATOR.
在 Windows 10 64 位中,没有任何项目设置建议对我有用。我改为发布,我用“requireAdministrator”行替换了“asInvoker”行,但仍然收到拒绝访问的异常。通过 VS2013 运行的唯一方法是以管理员身份立即运行环境。