【问题标题】:Custom Action changing InstallPrivileges自定义操作更改 InstallPrivileges
【发布时间】:2021-11-19 07:06:03
【问题描述】:

我正在编写一个位于顶部的 .wxs 文件

<Product Id="*" Name="My Fancy Product" Language="1033" Version="$(var.ProductVersion)" Manufacturer="My Company, Inc." UpgradeCode="AAA79BAB-B246-4326-B875-024022F393C6">
    <Package InstallerVersion="500" Compressed="yes" InstallPrivileges="limited" InstallScope="perUser" />

我需要根据特定条件将InstallPrivilegeslimited更改为elevated。 (我还需要为InstallScope 做类似的事情)。

我写了一个 C# 自定义动作:

    public static ActionResult SetElevated(Session session)
    {
        // Change InstallPrivileges to "elevated"
        session.Log($"Privileged = {session["Privileged"]}");
        session["Privileged"] = "1";
        session.Log($"{session["Privileged"]}");  // prints "1"

        session.Log($"ALLUSERS = {session["ALLUSERS"]}");
        session["ALLUSERS"] = "1";
        session.Log($"{session["ALLUSERS"]}");    // prints "1"

        return ActionResult.Success;
    }

自定义操作已安排:

<InstallUISequence>
  <Custom Action="SetElevatedCustomAction" Before="MyWelcomeDlg"></Custom>
  ...
</InstallUISequence>

<CustomAction Id="SetElevatedCustomAction" BinaryKey="SetupCustomActionBinary" DllEntry="SetElevated" Execute="immediate" Return="check"  />

但安装程序没有给出 UAC 提示。

我使用Orca 导出编译后的 MSI 中的所有表,并将其与使用InstallPrivileges="elevated" 生成的 MSI 进行比较,唯一的区别是 ALLUSERS 属性,我在自定义中将其设置为相同的值行动。

我的猜测是 ALLUSERS 不能从自定义操作中更改?那么如何动态地完成改变呢?谢谢。

【问题讨论】:

    标签: wix windows-installer elevated-privileges


    【解决方案1】:

    将自定义操作安排为尽早执行已修复:

    <InstallUISequence>
      <Custom Action="SetElevatedCustomAction" Before="LaunchConditions"></Custom>
      ...
    </InstallUISequence>
    
    

    【讨论】:

      猜你喜欢
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多