如何使用WiX安装程序使用提升的权限进行安装?

时间:2012-01-04 02:30:47

标签: wix

我们目前有一个使用WiX 3.5创建的MSI。该应用程序在.NET 3.5中。我们使用MSBuild文件中的boostrapper任务生成一个bootstrapper。它指向6.0a SDK个文件。

当用户启用UAC并安装时,他们必须右键单击setup.exe并选择run-as administrator。

我真正想要的是让setup.exe自动提示提升(使用我在其他安装中看到的黄色对话框)。

更好的是,我希望MSI能够完成这项工作并完全取消setup.exe,但我认为这就是WiX 3.6的用途,对吧?

如果我使用ApplicationRequiresElevation="true"创建了boostrapper,这需要7.0a SDK,对吗?然后引导程序会提示自动提升吗?这是否意味着应用程序必须是.NET 4应用程序?我不这么认为......

2 个答案:

答案 0 :(得分:14)

我们使用过WiX 3.0并且能够提升特权。但是,我们没有提升我们的引导程序。我们通过Package属性提升了MSI文件:

<Package Id="$(var.PackageCode)"
         Description="$(var.ProductName) $(var.Version)"
         InstallerVersion="301"
         Compressed="yes"
         InstallPrivileges="elevated"  <!-- Elevated right here -->
         InstallScope="perMachine"
         Platform="x86"/>

作为旁注,我们的引导程序使用我们的官方证书进行签名(使用v6.0A SDK中的signtool.exe)。我不确定这是否会导致引导程序也需要提升权限。

<强>更新

我们的setup.exe bootstrapper项目中有一个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 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>

答案 1 :(得分:0)

我知道这是一个古老的话题,但可能会为下一个节省一些时间 我必须阅读所有评论,特别是custom action had Impersonate=yes...

另一方面,自定义操作具有与权限相关的执行属性:

<CustomAction Id = "CA.First"  Execute ="immediate" ... />
<CustomAction Id = "CA.Second" Execute ="deferred"  ... />

CA.First将始终以用户模式执行,但CA.Second可以拥有提升的权限。

这里可能是与特权相关的其他技巧,
这里的主要观点 - WiX允许在CustomAction级别上进行控制权限,因此请确保将其设置正确。

CustomAction Element

相关问题