如何使用Visual Studio 2005中的清单文件以管理员权限运行应用程序? [英] How to run application with Admin privileges using Manifest file in Visual Studio 2005?

查看:114
本文介绍了如何使用Visual Studio 2005中的清单文件以管理员权限运行应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个需要在C:\Program Files,Users [username]和Sys32中创建文件/文件夹的应用程序。此外,应用程序需要进行一些注册表项。



此应用程序需要在Vista及更高版本上运行。此外,在Windows Server 2003及更高版本上。



上述操作系统具有用户帐户控制(UAC)的概念,访问程序文件和在注册表中写入需要的位置管理员权限。



我查看了许多论坛,发现使用Microsoft SDK我们可以检查当前用户是否具有管理员权限。但Vista和更高版本操作系统的功能CheckTokenMembership失败。



我还找到了一个解决方案,其中清单文件可用于提前告诉操作系统当前应用需要管理员权限。这是使用requestedExecutionLevel标签完成的。



我使用Visual Studio 2005来创建应用程序。当我们在Visual Studio中创建应用程序时,会创建一个默认的清单文件。我可以更改此清单文件以包含requestedExecutionLevel标记,以便我的应用程序始终以管理员权限运行吗?



是否有其他方法可以运行我的应用程序管理员权限而不要求用户(管理员或标准)以以管理员身份运行运行我的应用程序??



谢谢!

I need to create an application which needs to create files/folders in "C:\Program Files","Users[username]" and Sys32. Also the application needs to make some registry entry.

This application needs to work on Vista and higher. Also, on Windows Server 2003 and higher.

The above Operating Systems have the concept of User Account Control (UAC), where to access Program Files and writing in registry requires admin privileges.

I looked into many forums and found that using Microsoft SDK we can check whether the current user have admin privileges or not . But the function "CheckTokenMembership" fails for Vista and higher version of OS.

I also found a solution where manifest file can be used to tell OS in advance that the current application requires admin privileges. This is done using "requestedExecutionLevel" tag.

I am using Visual Studio 2005 to create the application. When we create an application in Visual Studio a default manifest file is created. Can I change this manifest file to include "requestedExecutionLevel" tag, so that my application always runs with admin privileges?

Is there any other method through which my application runs with admin privileges without asking user (admin or standard) to run my application as "run as admin"??

Thanks!

推荐答案

在Visual Studio中转到项目的Propertis页面,点击 Linker - >树视图中的清单文件。然后在右侧窗格中,在 UAC执行级别选择器中选择所需的权限。在所有情况下,除非关闭UAC,否则这将在Windows中引发提示。
Go to the Propertis page of your project in Visual Studio, click on Linker -> Manifest File in the tree view. Then in the right hand pane select the privilege you require in the UAC Execution Level selector. In all cases this will raise the prompt in Windows unless UAC is turned off.


这篇关于如何使用Visual Studio 2005中的清单文件以管理员权限运行应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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