如何使用 WiX 安装程序以提升的权限进行安装? [英] How do I install with elevated permissions using a WiX installer?

查看:29
本文介绍了如何使用 WiX 安装程序以提升的权限进行安装?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

We currently have an MSI that is created with WiX 3.5. The application is in .NET 3.5. We generate a bootstrapper using the boostrapper task in an MSBuild file. It's pointing at the 6.0a SDK files.

当用户打开 UAC 并安装时,他们必须右键单击 setup.exe 并选择以管理员身份运行.

When users have UAC on and they install, they have to right-click the setup.exe and select run-as administrator.

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

What I would really like is to have the setup.exe automatically prompt to elevate (using that yellow dialog I see in other installs).

更好的是,我希望 MSI 执行此操作并完全取消 setup.exe,但我认为这就是 WiX 3.6 的意义所在,对吗?

Better yet, I'd like the MSI to do this and do away with the setup.exe completely, but I think that is what WiX 3.6 is about, right?

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

If I create the boostrapper using ApplicationRequiresElevation="true" this requries the 7.0a SDK, correct? Will the bootstrapper then prompt to elevate automatically? Does this mean the application has to be a .NET 4 application? I wouldn't think so...

推荐答案

我们已经使用了 WiX 3.0 并且能够提升权限.然而,我们并没有提升我们的引导程序.我们通过 Package 属性提升了 MSI 文件本身:

We've used WiX 3.0 and were able to elevate privileges. However, we didn't elevate our bootstrapper. We elevated the MSI file itself, through the Package property:

<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).我不确定这是否会导致引导程序也需要提升权限.

As a side note, our bootstrapper is signed (using signtool.exe from the v6.0A SDK) with our official certificate. I'm not sure if this causes the bootstrapper to also require elevated privileges.

更新:

我们的 setup.exe 引导程序项目中有一个 app.manifest 文件,需要在管理员级别运行可执行文件.请参阅下面的示例:

We've got an app.manifest file on our setup.exe bootstrapper project that requires the executable to be run at the administrator level. See the sample below:

<?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>

这篇关于如何使用 WiX 安装程序以提升的权限进行安装?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆