通过 属性 的 WiX 静默安装条件

WiX silent install condition via property

是否可以通过 WiX 安装程序中的条件在没有“/q”参数的情况下进行静默安装?

我有一个 UIRef 和一个值为 1 的静默 属性,现在如果 属性 为 1,我想安装静默。

WiX GUI:老实说,我从来没有见过这个,我不会推荐它。一些 MSI 文件根本没有 GUI,然后它们在没有任何 GUI 的情况下安装 - 很明显。我想这是一个不可接受的选择。

条件:我看了一下,调理了WelcomeDlg InstallUISequence 中的条目可能有效,但我发现这是一个非常奇怪的设计:

  1. 使用 Orca 并将此条件添加到 WelcomeDlg(NOT Installed OR PATCH) AND (NOT SILENT=1)
  2. 同时在 Property table 中添加一个条目; SILENT=0 以避免静音成为默认 运行 模式

现在您可以尝试双击 MSI,您将看到对话框。如果你使用下面的命令行,应该没有对话框,但你会看到一个进度条,你会得到 UAC 提升提示:

msiexec.exe /i MySetup.msi SILENT=1

WiX Snippet: Here is the markup you can try to use. No guarantees! :-). I can replace with a full "small runnable" sample if requested - the below is just what you can "slipstream" into a working setup. You also need to change the maintenance mode / uninstall dialogs if you want uninstall, modify and repair to be silent. Making modify silent sort of does not make sense.

Please remember that the markup is a "hack" and has not been fully tested in all installation modes: install, modify, repair, self-repair, patch, resume suspended, uninstall, major upgrade uninstall, etc... - please test accordingly - there are always surprises:

<..>

<Property Id="SILENT" Value="0" />
<UIRef Id="WixUI_Mondo" />

<..>

<InstallUISequence>
  <Show Dialog="WelcomeDlg" After="ResumeDlg">(NOT Installed OR PATCH) AND (NOT SILENT=1)</Show>
  <Show Dialog="ExitDialog" OnExit="success">(NOT SILENT=1)</Show>
</InstallUISequence>

<..>

注意! 这样的结构在现实生活中往往适得其反。突然间,您在一些晦涩的安装模式(暂停恢复、补丁、修改或类似)中看到了您从未预料到的问题。如果你想用这个,一定要测试好。

请注意,还有其他对话框 - 例如修改和修复(维护模式对话框) - 仍会显示。如果您希望它们表现不同,您也必须对它们进行调节(并且可能坚持使用 SILENT 属性 来确定是否要抑制对话).