我的安装程序部署了一个配置EXE,该配置用于在Windows服务上进行一些基本配置,该配置也已安装。 EXE还需要创建和编写一些注册表键。在Windows Server 2008环境上,这些键无法创建。我已经调查并发现这是管理员特权,EXE并未提示2008年UAC下需要的管理权限。我可以通过右键单击EXE并作为管理员运行来解决此问题。但是,这不是理想的选择,因为我需要通知客户表演的额外步骤。运行EXE时,还有其他方法可以提高管理员权限吗?

有帮助吗?

解决方案

在EXE上或与Exe一起放置一张清单。如果您让我知道您正在使用的版本,我可以告诉您如何使用Visual Studio嵌入清单。如果您不使用Visual Studio,或者不使用EXE,则可以将清单文件放在与EXE同一文件夹中,并且也可以工作。在这种情况下,文件必须与您的exe相同,最终具有.manifest,例如foo.exe,是foo.exe.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 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.
        -->
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>

请注意,请求的ExecutionLevel的可能值都在这里注释,并且此人使用了sighteadministrator。现在它将始终提升,因此为您工作。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top