如何使.exe文件编程设置为管理员总是在Vista中运行? [英] How to make .exe file programmatically set to run as admin always in vista?

查看:144
本文介绍了如何使.exe文件编程设置为管理员总是在Vista中运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写在C#的winform应用程序。当我运行该程序的一些功能也需要管理员权限。安装后,如果我设置.exe文件作为管理员手动运行(通过点击.exe文件,点击鼠标右键),然后我的程序运行完美。

I have written a winform application in C#. When I run the program for some functionality it required admin permission. After Installation If I set the .exe file to run as admin manually (by clicking right mouse button on .exe file) then my program run perfectly.

现在我需要的用户无法通过单击鼠标右键来设置安装后运行的管理特性。我需要在C用户无需理会这个$ C $某处设置该programaticaly。仅出现这一特定问题适用于Windows Vista。谁能帮助我?

Now I need user not to set the run as admin property after installation by clicking right mouse button. I need to set this programaticaly somewhere in the code that user no need to bother about this. This specific problem is only arise for Windows Vista. Can anyone help me out?

推荐答案

您需要添加一个清单的应用程序,指定它需要管理员权限。 了解更多关于MSDN

You need to add a manifest to the app that specifies it require admin privileges. Read more on MSDN.

更新:您可以通过右键单击添加一个清单到您的项目在项目并选择添加 / 新项目 / 应用程序清单文件。这将app.manifest添加一个名为新文件到您的项目,将引用从项目属性,在对应用程序清单下拉列表code>设置页。默认的清单文件,即使对究竟如何改变所需要的UAC执行水平一个很好的注释。

Update: You can add a manifest to your project by right-clicking on the project and selecting Add / New Item / Application Manifest File. This will add a new file called app.manifest to your project and will reference it from the project properties, in the Manifest dropdown on the Application tab. The default manifest template even has a nice comments on how exactly to change the required UAC execution level.

这篇关于如何使.exe文件编程设置为管理员总是在Vista中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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