从 WIX 安装程序执行 dism 批处理命令

Executing dism batch command from WIX installer

我创建了一个 WIX msi 安装程序,它使用 dism.exe 执行批处理命令以启用 IIS windows 功能。当我执行 msi 安装程序时,执行的命令没有生效,所需的 windows 功能也没有启用,控制面板也没有显示安装了新的应用程序,但是当我 运行使用命令行参数的相同 msi 安装程序:

msiexec /i BatchFileExecutor.msi /Lime logfile.txt

所需的 windows 功能已启用,控制面板显示应用程序已安装。

下面是我使用的WIX代码:

<CustomAction Id="BatchCmd"
              Property="BatchRun"
              Value='"[WindowsFolder]Sysnative\dism.exe" /Online /Enable-Feature /FeatureName:IIS-WebServerRole"' 
              Execute='immediate' 
              Return='check'>
</CustomAction>

<CustomAction Id="BatchRun" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="yes">
</CustomAction>

<InstallExecuteSequence>
  <Custom Action="BatchCmd" Before="BatchRun">NOT Installed</Custom>
  <Custom Action="BatchRun" After="InstallFiles">NOT Installed</Custom>
</InstallExecuteSequence>

是否有一些代码片段不合适或者我错误地设置了一些属性?

customaction 值属性对我来说似乎没有正确数量的“。请注意,QuietExecCA 需要用引号括起 EXE 的完整路径,但我认为不需要”在功能名称之后。

此外,您不希望模拟您的延迟 CA。您不需要模拟,因此它会在系统上下文中提升运行。

最后,我肯定会添加一些开关,以防止 DISM 在安装过程中强制重启。某些 windows 功能需要重新启动才能生效。出于这个原因,我将 DISM 命令作为它们自己的包放在我的 MSI 之外的引导程序包/链中。