0

I have created MSI using WIX 3.11. I have made some customization to the Installer to install the application in a custom folder. I am also writing Install path to registry value under HKLM\Software.

I am reading registry value in batch file for one of my use-case.

Installation is successful and the application is running fine.

But while uninstalling, I am facing below issue -

Uninstall window pops up with the message - The following applications should be closed before continuing the Install: [MyApplication]

In uninstall log while removing the service, I see below error - Error 1722. There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor.

If I remove the service manually, no errors can be seen and the service is getting deleted. Not sure why Uninstall is failing.

Please shed some light on this.

vkreddy
  • 181
  • 6
  • 18

1 Answers1

1

Stop Service Before Uninstall: In the compiled MSI, what entries do you have in the ServiceControl table? You need to stop the service before its executable is deleted. See WiX service installation sample linked to below.

Failing Custom Action: It is also possible that you have a custom action which tries to run a batch file that has already been uninstalled when you try to run it. This can be a custom action that should not run on uninstall (conditioning is wrong), or you have sequenced it incorrectly so the batch file is gone from disk - courtesy of the uninstall - before the custom action can run successfully. You need to move the custom action earlier in the installation / un-installation sequence or condition it better so it never runs on uninstall. Both issues are very common. Be aware that it is common to fail to condition custom actions so they run unexpectedly. Very often they run during major upgrade uninstalls undesirably.

Batch Files CAs: For what it is worth - and no offense: using batch files in custom action is an MSI anti-pattern in my opinion. There is basically zero error handling and hence no management and recovery from error conditions. And generally no MSI rollback support. C++ custom actions are best in my view (minimal dependencies, good debugability, full featured language, large down-to-the-metal API). Just so it is mentioned. It all depends how large your distribution is. For in-house appliations one can get away with more than for truly global package distribution. This has to do with the complexity of deployment (see section a bit down the page). There are so many error sources.

WiX Service Installation: Maybe see this hands on WiX-markup sample from Rainer Stropek: WiXSamples - github.com/rstropek. Please check the ServiceControl element.


Common MSI Problems: I hate to "pitch" this content. It is essentially the things you can't easily find in books - and for good reason. Some rules of thumb and opinions in a chaotic form, but here it is if you want to check it out: How do I avoid common design flaws in my WiX / MSI deployment solution? Just honest opinions and practical advice - no claim to be "right", but it should help setup reliability. Hopefully.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Thank you @Stein. I have written custom action(This makes use of batch file) to stop and delete one of the service. Once the service is deleted, I am deleting install Dir using another custom action. Uninstaller fails at deleting service because of the following reason - Uninstaller deleting all the files(Including batch file that deletes service) before this custom action gets called. In the uninstall log I could see the message **Allowing uninstallation of shared component: {97139BA1-3F3B-4CF5-ADC7-9188F79006A3}. Other clients exist, but installed to a different location** – vkreddy Aug 08 '18 at 07:30
  • I have installed MSI in a fresh machine, Even then I am seeing above issue. Wondering how uninstaller is looking deleting the file thinking that Other Clients exist but installed to a different location. – vkreddy Aug 08 '18 at 11:06
  • The same installer was working properly when installed in a predefined path. I have made changes to install in custom path and now the uninstaller is not working as expected. – vkreddy Aug 08 '18 at 16:05
  • Service stopping and deleting is fully supported by MSI and you should not resort to batch files to achieve this. Did you visit the link to Rainer Stropek's sample above? [***`Adding the ServiceControl element and setting the service to stop and start on install and stop and delete on uninstall should solve your problems and eliminate the batch file`***](https://github.com/rstropek/Samples/blob/master/WiXSamples/WindowsService/ServiceInstaller/Product.wxs). You should also not delete the installation directory with a custom action - that will happen automagically once you do things "vanilla". – Stein Åsmul Aug 08 '18 at 20:32
  • It also looks like you have messed up the component referencing judging from that log file message. I would recommend you test on a clean virtual. And [**please read about the component GUID concept**](https://stackoverflow.com/questions/1405100/change-my-component-guid-in-wix/1422121#1422121) and how it is intended to be set in stone for an absolute installation path. – Stein Åsmul Aug 08 '18 at 20:34
  • Thank you @Stein. I am working on Adding the Service Control element in my installer and also I have gone through the links which you provided and learned couple of things. One last thing, Uninstaller removes only the directories and files that were originally installed from the MSI file and it leaves everything else that was added later in the Install Directory. In another words, I'd like to purge the directory when uninstalling. How do I do that with out Custom action? Could you please guide me. – vkreddy Aug 09 '18 at 09:16
  • What is the content you want to remove? MSI offers the [RemoveFile table](https://learn.microsoft.com/en-us/windows/desktop/msi/removefile-table) to specify files names of files that are to be removed on uninstall - for example log files. If the folder is empty after all remove operations are complete, the folder is removed as well. In WiX you use the [RemoveFile Element](http://wixtoolset.org/documentation/manual/v3/xsd/wix/removefile.html) to specify files to remove. There are also other remove elements, maybe search for "remove" here: http://wixtoolset.org/documentation/manual/v3/ – Stein Åsmul Aug 09 '18 at 09:38
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/177713/discussion-between-vkreddy-and-stein-asmul). – vkreddy Aug 09 '18 at 10:05