C# 让程序自动以管理员身份运行
来源:互联网 发布:917自动发卡平台源码 编辑:程序博客网 时间:2024/05/17 06:37
C# 让程序自动以管理员身份运行
2011年07月28日 19:05 来源:Lemon_s的博客 作者:Lemon_s 编辑:胡铭娅
选中"Security",在界面中勾选"Enable ClickOnce Security Settings"后,在Properties下就有自动生成app.manifest文件。
打开app.manifest文件,将
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
改为
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
修改后的app.manifest为:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assemblymanifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentityversion="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivilegesxmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevellevel="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequestpermissionSetReference="Custom"/>
<PermissionSetclass="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site"/>
</applicationRequestMinimum>
</security>
</trustInfo>
</asmv1:assembly>
<asmv1:assemblymanifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentityversion="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivilegesxmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevellevel="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequestpermissionSetReference="Custom"/>
<PermissionSetclass="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site"/>
</applicationRequestMinimum>
</security>
</trustInfo>
</asmv1:assembly>
然后在"Security"中再勾去"Enable ClickOnce Security Settings"后,重新编译即可。
- C# 让程序自动以管理员身份运行
- C# 让程序自动以管理员身份运行
- C#让程序自动以管理员身份运行
- C# 让程序自动以管理员身份运行
- C# 让程序自动以管理员身份运行
- C# 让程序自动以管理员身份运行
- 让C#程序自动以管理员身份运行
- C# 让程序自动以管理员身份运行
- 让程序自动以管理员身份运行
- 让程序自动以管理员身份运行
- 如何让Delphi程序启动自动“以管理员身份运行"
- 在VS中如何让C#语言编写的程序自动以管理员身份运行
- 如何让自己的程序以管理员身份运行 C#
- C#程序如何以管理员身份自动运行
- C#程序如何以管理员身份自动运行
- 如何以管理员身份自动运行 程序
- 如何自动以管理员身份运行程序
- C#默认以管理员身份运行程序
- 如何使用kaptcha来生成验证码?
- FlashPlayer版本对应-swf-version
- js+JQuery实现返回顶部功能
- 制作16M ramdisk -- qemu测试用
- iOS6.0 消息推送的原理与实现
- C# 让程序自动以管理员身份运行
- 棋牌游戏和其他类型游戏的差异
- QQ已经被恶意外挂破坏
- Asterisk realtime 之SIP用户动态写入mysql 数据库
- AjaxPro使用方法
- QC11新特性 【】HP Application Lifecycle Management 11.00
- iphone/ipad 图片位置说明
- java环境变量配置&tomcat配置
- 如何用workbench导出mysql数据库关系图