zoukankan      html  css  js  c++  java
  • C# 程序软件启动默认管理员权限。

    在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>
  • 相关阅读:
    SpringIoC和SpringMVC的快速入门
    Swoole引擎原理的快速入门干货
    Windowns 10打开此电脑缓慢问题的一种解决办法
    CentOS下使用Postfix + Dovecot + Dnsmasq搭建极简局域网邮件系统
    CentOS7.2 创建本地YUM源和局域网YUM源
    CentOS 7.2 安装配置Samba服务器
    Zookeeper 日志输出到指定文件夹
    MySQL索引优化-from 高性能MYSQL
    Transaction事务注解和DynamicDataSource动态数据源切换问题解决
    Redis使用经验之谈
  • 原文地址:https://www.cnblogs.com/zbfamily/p/6269335.html
Copyright © 2011-2022 走看看