开发者

Closing an application using WiX

开发者 https://www.devze.com 2022-12-11 04:34 出处:网络
In creating my WiX installer I have run into an issue when trying to close an application before installing the upgrade. Below is an example of how I am attempting to do this.

In creating my WiX installer I have run into an issue when trying to close an application before installing the upgrade. Below is an example of how I am attempting to do this.

<util:CloseApplication Id="CloseServe" CloseMessage="yes" Target="server.exe" ElevatedCloseMessage="yes" RebootPrompt="no"/>
<InstallExecuteSequence>      
  <Custom Action="WixCloseApplications" After="RemoveExistingProducts" />
  <RemoveExistingProducts After="InstallInitialize"/>
  <Custom 开发者_如何转开发Action='LaunchApplication' After='InstallFinalize'/>
  <!--<Custom Action='StopServer' Before='RemoveExistingProducts'/>-->
</InstallExecuteSequence>

Using this example the application does end up closing but the installation gets stalled at that point and then performs a rollback. Could this be due to the fact that the exe is removed prior to trying to close it? I have tried changing the sequence around so that RemoveExistingProducts is performed after the WixCloseApplications but it then gives me an error code 2613.


You could try logging the installation and see what you can track down from there. Try running the installer from the command console like so:

msiexec.exe /i [msi filename] /log [filepath\logfilename.log]


UPDATE: Newer sample of WiX CloseApplication


I would assume that you need to close the running application as early as possible in the InstallExecuteSequence, and certainly before InstallInitialize which starts the Windows Installer transaction that makes changes to the system.

In addition you should run the same ApplicationClose operation in the InstallUISequence as well so the application is closed while you cycle through the installation menus interactively. The whole InstallUISequence is skipped when you install silently, so you need it in the InstallExecuteSequence as well.

Be aware that you can accidentially trigger rollback in a custom action by returning an exit code / error code that msiexec.exe interprets as an error. If the completion of the custom action isn't crucial, I turn off error checking to allow the install to continue. In this case that would just cause a reboot to be required.

If what you are trying to close or shut down is a service, MSI has built-in features to deal with this via the ServiceControl and ServiceInstall elements (and others).

0

精彩评论

暂无评论...
验证码 换一张
取 消