如何请求管理员权限的程序启动时?

编程入门 行业动态 更新时间:2024-10-27 08:38:56
本文介绍了如何请求管理员权限的程序启动时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要我的软件,能够为在Windows Vista(如果有人运行它没有管理权限,它会崩溃)管理员身份运行。

在启动其他软件,我已经看到了提示被系统像这个软件会以管理员身份运行。你要继续吗?当应用程序试图获取管理权限。

如何运行在Windows Vista?

这是C#应用程序的时候,我要求管理员权限解决方案

以下内容添加到您的清单文件:

< requestedExecutionLevel水平=requireAdministratoruiAccess =FALSE/>

您也可以使用 highestAvailable 的水平。

看这里有关嵌入清单文件:

msdn.microsoft/en-us/library/bb756929.aspx

PS:如果你没有一个清单文件,你可以方便地添加一个新的:

在Visual Studio中,右键单击项目 - >添加项目 - >选择应用程序清单文件(一般下的Visual C#项目)

添加的文件已经拥有上述的一部分,只是改变从 asInvoker

I need my software to be able to run as administrator on Windows Vista (if someone runs it without administrative permissions, it will crash).

When launching other software, I've seen a prompt by the system like "this software will run as administrator. do you want to continue?" when the app was trying to acquire administrative privileges.

How do I request administrative privileges when running an c# app on Windows Vista?

解决方案

Add the following to your manifest file:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

You can also use highestAvailable for the level.

Look here about embedding manifest files:

msdn.microsoft/en-us/library/bb756929.aspx

PS: If you don't have a manifest file, you can easily add a new one:

In Visual Studio, right click project -> Add Item -> Choose Application Manifest File ( under General for Visual C# items)

The added file will already have the above part, just change the level to requireAdministrator from asInvoker

更多推荐

如何请求管理员权限的程序启动时?

本文发布于:2023-11-10 01:49:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574024.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:启动时   管理员权限   程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!