管理员访问提示的清单

时间:2014-07-24 12:24:33

标签: c# admin manifest

我有一个小帮助项目。现在,我通过右键单击鼠标然后指定'以管理员身份运行来运行该项目的.exe(ABC.exe)。

但是,我需要有一个清单,我只需双击.exe文件,Windows将提示我询问是否应继续管理员权限。 (是/否/取消消息框)

我已使用此代码将清单文件(ABC.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" />

            Specifying requestedExecutionLevel node will disable file and registry virtualization.
            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>

我有两个问题 -

  1. 这是实现目标的正确方法吗?
  2. 如果是的话,是否有人可以了解这究竟是如何运作的?我担心我只有暴露的知识信息,而不是深度知识,而且与此问题具体相关。
  3. 谢谢!

0 个答案:

没有答案