C# 程序软件启动默认管理员权限。

摘要:
--UAC清单选项如果要更改Windows用户帐户控制级别,请用以下节点之一替换requestedExecutionLevel节点。指定requestedExecutionLevel节点将会禁用文件和注册表虚拟化。如果要利用文件和注册表虚拟化实现向后兼容性,则删除requestedExecutionLevel节点。--此应用程序设计使用的所有Windows版本的列表。Windows将会自动选择最兼容的环境。--启用Windows公共控件和对话框的主题--˃˂!

在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="1" Unrestricted="true" ID="Custom" SameSite="site" />
      </applicationRequestMinimum>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!-- 此应用程序设计使用的所有 Windows 版本的列表。Windows 将会自动选择最兼容的环境。-->
      <!-- 如果应用程序设计使用 Windows 7,请取消注释以下 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# 程序软件启动默认管理员权限。》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇DDR工作原理【转】yaml,json,ini这三种格式用来做配置文件优缺点下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

linux,xshell命令

一. linux 1.Linux发行版 <1> 常见的发行版本如下: Ubuntu Redhat Fedora openSUSE Linux Mint Debian Manjaro Mageia CentOS Arch 2.Linux和Windows区别 比较 Windows Linux 费用 收费且很贵 Linux免费或少许费用...

转录本组装软件StringTie的使用说明

转录本组装软件StringTie的使用说明 StringTie 转录本组装软件StringTie的使用说明 转录组分析流程 HISTA + StringTie 组合。其Protocol 发表在Nature Protocol 上“Transcript-level expression analysis of RNA-seq experiments wit...

AHK教程

转自:小弗兰茨 AHK,就是传说中的 Auto Hot Key 。什么?没有听说过?那么很正常……它运行在Windows下。总之,AHK可以赋予你对你的电脑的无与伦比的控制力。一些人想要在MM面前展示技术的,我是说很炫的技术——一般人能看懂的技术的,那么学一学AHK吧。 快速入门之:开始 首先,你需要去下载AHK,我想这个不用我告诉你了。搜索一下吧,很容...

泛微OA系统多版本存在命令执行漏洞

0x01漏洞描述 泛微OA办公系统是一款协调办公软件。 泛微协同商务软件系统存在命令执行漏洞,攻击者可利用该漏洞获取服务器权限。 0x02漏洞危害 攻击者可以通过精心构造的请求包在受影响版本的泛微OA上进行远程代码执行。 0x03影响范围 泛微 e-cology<=9.0 0x04漏洞复现 访问http://url/weaver/bsh.se...

RPC 超时设置 分析 转

出处:RPC 超时设置   上面这张监控图,对于服务端的研发同学来说再熟悉不过了。在日常的系统维护中,『服务超时』应该属于监控报警最多的一类问题。   尤其在微服务架构下,一次请求可能要经过一条很长的链路,跨多个服务调用后才能返回结果。当服务超时发生时,研发同学往往要抽丝剥茧般去分析自身系统的性能以及依赖服务的性能,这也是为什么服务超时相对于服务出错和服...

Docker在Linux上运行NetCore系列(一)配置运行DotNetCore控制台

系列文章:https://www.cnblogs.com/alunchen/p/10121379.html 本篇文章操作系统信息       Linux:ubuntu 16.04.3 amd64 查看NetCore支持的Linux系统       NetCore不是支持Linux的所有系统,只支持部分,所以在Linux上安装NetCore之前要查看系...