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


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

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

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

更好的是,我希望MSI能够做到这一点并取消它 setup.exe 完全,但我认为这就是WiX 3.6的意义,对吧?

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


5887
2018-01-04 02:30


起源



答案:


我们使用过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>

13
2018-01-04 02:53



谢谢,我已经安装了类似这样的InstallPrivleges但它似乎没有做任何有用的事情。直接运行MSI将无法提升。哦,但我刚注意到InstallerVersion设置为300.我想知道是不是这样.... - Jonesie
@Jonesie:如果你明天没有得到一个好的答案,我会在工作时仔细看看我们的东西。我或许可以挖掘更多信息。 - Jason Down
队友的欢呼声!我需要通过我们的构建服务器运行它,这需要一个小时,所以它很慢,一次尝试1件事:) - Jonesie
@Jonesie:我只是远程连接看看......我们的setup.exe项目中有一个app.manifest文件。它有一个部分,要求在引导程序上使用管理员权限。查看我的更新。 - Jason Down
自定义操作具有Impersonate = yes。删除它修复了CA,现在一切都很顺利。干杯 - Jonesie


答案:


我们使用过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>

13
2018-01-04 02:53



谢谢,我已经安装了类似这样的InstallPrivleges但它似乎没有做任何有用的事情。直接运行MSI将无法提升。哦,但我刚注意到InstallerVersion设置为300.我想知道是不是这样.... - Jonesie
@Jonesie:如果你明天没有得到一个好的答案,我会在工作时仔细看看我们的东西。我或许可以挖掘更多信息。 - Jason Down
队友的欢呼声!我需要通过我们的构建服务器运行它,这需要一个小时,所以它很慢,一次尝试1件事:) - Jonesie
@Jonesie:我只是远程连接看看......我们的setup.exe项目中有一个app.manifest文件。它有一个部分,要求在引导程序上使用管理员权限。查看我的更新。 - Jason Down
自定义操作具有Impersonate = yes。删除它修复了CA,现在一切都很顺利。干杯 - Jonesie


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

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

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

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

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

CustomAction元素


0
2017-09-21 12:54