WiX <util:closeapplication>元素无法正常工作</util:closeapplication>

时间:2013-11-16 08:48:52

标签: wix windows-installer burn

我正在运行WiX捆绑软件安装。其中一个MSI软件包应该在运行时关闭应用程序:

<util:CloseApplication Id="CloseApplication" Target="My App.exe">1</util:CloseApplication>

这是<Product>元素之前的<Feature>元素。我添加了1以确保条件成立。

MSI日志可以这样说:

MSI (s) (14:94) [21:30:13:979]: Doing action: WixCloseApplications
Action ended 21:30:13: CreateFolders. Return value 1.
MSI (s) (14:68) [21:30:13:993]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI5D24.tmp, Entrypoint: WixCloseApplications
MSI (s) (14!CC) [21:30:14:023]: PROPERTY CHANGE: Adding WixCloseApplicationsDeferred property. Its value is 'My App.exe2'.
Action start 21:30:13: WixCloseApplications.
MSI (s) (14!CC) [21:30:14:023]: Doing action: WixCloseApplicationsDeferred
Action start 21:30:14: WixCloseApplicationsDeferred.
Action ended 21:30:14: WixCloseApplicationsDeferred. Return value 1.
MSI (s) (14:94) [21:30:14:052]: Doing action: InstallFiles
Action ended 21:30:14: WixCloseApplications. Return value 1.
Action start 21:30:14: InstallFiles.

如果我将提示设置为'no',请执行以下操作:

<util:CloseApplication Id="CloseApplication" Description="Closing running application" Target="My App.exe" RebootPrompt="no" ElevatedCloseMessage="no" CloseMessage="no">1</util:CloseApplication>

日志说明了这一点:

MSI (s) (50:04) [21:43:40:214]: Doing action: WixCloseApplications
Action ended 21:43:40: CreateFolders. Return value 1.
MSI (s) (50:14) [21:43:40:238]: Invoking remote custom action. DLL: C:\Windows\Installer\MSIFFA9.tmp, Entrypoint: WixCloseApplications
Action start 21:43:40: WixCloseApplications.
MSI (s) (50:04) [21:43:40:333]: Doing action: InstallFiles
Action ended 21:43:40: WixCloseApplications. Return value 1.
Action start 21:43:40: InstallFiles.

无论哪种方式安装完成,但原始应用程序仍在运行,并且不会关闭。

有问题的应用程序是WPF应用程序,我有<MajorUpgrade Schedule="afterInstallExecute" ...,安装程序使用从WiXBA修改的托管boostrapper运行。

1 个答案:

答案 0 :(得分:7)

我也无法让CloseApplication工作,我没有付出太多精力,但我正在使用不同的方法来关闭使用taskkill和QtExec的应用程序:

<Property Id="QtExecCmdLine" Value='"[WindowsFolder]\System32\taskkill.exe" /F /IM APP.EXE'/>
<CustomAction Id="APP.TaskClose" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="immediate" Return="ignore"/>

<InstallExecuteSequence>
  <Custom Action="APP.TaskClose" After="InstallInitialize"/>
</InstallExecuteSequence>

注意这是immediate CA,要运行它deffered,请查看wix文档:http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html