在vs的Properties目录中找到 app.manifest,
将其中level="asInvoker" 改成 level="requireAdministrator"就可以了,
如果没有app.manifest文件可以打开项目属性,找到“安全性”,勾上“启用 ClickOnce 安全设置”,会生成app.manifest文件,然后再把勾去掉
这样你重新编译,你的程序图标上就会出现个小盾牌了,就自动以管理员身份运行你的程序,无需右键打开。

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="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">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果要更改 Windows 用户帐户控制级别,请用以下节点之一替换
requestedExecutionLevel 节点。 <requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> 指定 requestedExecutionLevel 节点将会禁用文件和注册表虚拟化。
如果要利用文件和注册表虚拟化实现向后
兼容性,则删除 requestedExecutionLevel 节点。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="" Unrestricted="true" ID="Custom" SameSite="site" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 此应用程序设计使用的所有 Windows 版本的列表。Windows 将会自动选择最兼容的环境。-->
<!-- 如果应用程序设计使用 Windows ,请取消注释以下 supportedOS 节点-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
</application>
</compatibility>
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>

C# 程序软件启动默认管理员权限。的更多相关文章

  1. 让.net程序自动运行在管理员权限下

    原文:让.net程序自动运行在管理员权限下 如何让.net程序自动运行在管理员权限下 VS2010 c# 编译的WINFORM程序 在Win7 以管理员身份运行 windows 7和vista提高的系 ...

  2. 【转】vc++MCF/C++/C中怎样让应用程序获得或以管理员权限运行 ,ShellExecuteEX编程 --- 获取管理员权限

    ShellExecuteEX编程 --- 获取管理员权限:http://blog.csdn.net/jhui163/article/details/5873027 怎样让你的应用程序获得管理员权限:就 ...

  3. Win7,Vista UAC下应用程序标注为“需要管理员权限”的四种方法(可以修改注册表)

    [转]Vista UAC下应用程序标注为“需要管理员权限”的四种方法 在Microsoft 的UACBlog里对此有过叙述.总结如下: 首先,如果一个程序被识别为管理员程序时,Vista会在它的图标上 ...

  4. windows程序 UAC设置,程序运行提示使用管理员权限运行的方法

    在近期的任务中需要对光盘中的程序运行时获取管理员权限运行程序.这个功能的实现需要改变工程的配置. 在vs2015中,使用鼠标右击解决方案管理器中的工程->属性->链接器->清单文件. ...

  5. VS2017设置默认管理员权限启动

    找到vs安装目录下的:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe 右键- ...

  6. VS2019/VS2017设置默认管理员权限启动

    找到vs安装目录下的:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe 右键- ...

  7. WIN8,开机启动 需要管理员权限的程序

    1. 用WPF开发,需要管理员权限并开机启动,以写注册表的方式实现.仅写注册表只能启动一般权限的程序. 2. 考虑这样实现: 程序以一般权限启动,启动以后申请管理员权限. 实现: App类中重写OnS ...

  8. Vista UAC下应用程序标注为“需要管理员权限”的四种方法

    在Microsoft 的UACBlog里对此有过叙述.总结如下: 首先,如果一个程序被识别为管理员程序时,Vista会在它的图标上加上一个盾牌标记.因此很容易看出来. 其次,如果UAC有效的话,管理员 ...

  9. windows Service启动带有管理员权限的GUI进程

    事情是这样的,公司的产品有个守护进程(windows Service)需要启动产品的主程序exe,让主程序它运行为管理员权限(因为主程序会加载一个插件,插件中有列出端口监听的功能,需要由端口查找到进程 ...

随机推荐

  1. java ArrayList倒序

    用Collections.reverse(list)即可.如:List<String> list = Arrays.asList(new String[] {"aa", ...

  2. jackrabbit官方英文文档加补充(转载)

    关于Jackrabbit To get started with Jackrabbit you should first become familiar with the JCR API. Downl ...

  3. android启动另一应用

    http://www.2cto.com/kf/201203/122910.html Android SDK中有这样一个API: public abstract Intent getLaunchInte ...

  4. SPOJ - GSS1&&GSS3

    GSS1 #include<cstdio> #include<iostream> #define lc k<<1 #define rc k<<1|1 u ...

  5. if __name__

     我们经常在python 程序中看到 if __name__ == '__main__' :这代表什么意思?    python中 模块是对象,并且所有的模块都有一个内置属性 __name__.一个模 ...

  6. jquery ui 怎么实现tab标签切换效果

    1.效果图 2.HTML 代码 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> &l ...

  7. Timing breakdown phases explained

    https://developers.google.com/web/tools/chrome-devtools/network-performance/reference#timing-explana ...

  8. Remote Debugging Android Devices

    Remote Debugging Android Devices //在电脑上远程调试安卓设备 By Kayce Basques Technical Writer at Google By Meggi ...

  9. java.lang.ClassNotFoundException: Didn't find class "org.reactivestreams.Publisher" on path

    缺少jar包  reactive-streams-1.0.0.jar  和  reactive-streams-1.0.0-sources.jar 常用于  Rxjava 开发过程中 <?xml ...

  10. socket 学习笔记

    #include <sys/socket.h> ---------------------------------------------------------------------- ...