While I was trying to make the new client installer uninstall previous versions of our software, I ran into a few issues that took a while to solve.
First and foremost, the previous installer (custom-built) didn't contain an upgrade code (which uniqely identifies a product across versions) that I could use in my new MSI installer's upgrade table to make sure it was uninstalled. This was simple, just create a custom action that reads the uninstall information from the registry and runs the uninstall string if it exists for your product.
Next I tried to tell Windows installer to remove two additional products that were installed using MSI installers. I used the upgrade table with the upgrade codes from the two products I wanted to uninstall.
When running the installer, only one of the products were removed, and the log told me that the other one was skipped because it was installed in a different context (machine, not for this user only).
When I removed the product that successfully was uninstalled and reran the installation, the product that was previously skipped was uninstalled! This baffled me, and I tried a lot of different solutions until I finally had to revert to a rather dirty solution.
First of all, this is whats happening when you are uninstalling previous products:
- When the installer runs the FindRelatedProducts action, it looks in the Upgrade table to find what products it should search for. If it finds a product installed (using the UpgradeCode in the Upgrade table), it sets the value of the property (actionprop column) for the product in the Upgrade table to the Product code (installed version of product)
- The uninstallation happens in the RemoveExistingProducts action which uninstalls those products marked for uninstallation (from the FindRelatedProducts action)
The problem in my case was that the FindRelatedProducts action skipped one of the products, so I had to include a small vbscript that was run before the RemoveExistingProducts action that found the product code for the product I wanted to remove and updated the according property so that it would be uninstalled:
set oWI = CreateObject("WindowsInstaller.Installer")
set related = oWI.RelatedProducts("YOUR_UPGRADECODE_HERE")
if related.Count = 1 then
Property("ACTIONPROPERTY_NAME_HERE") = related.Item(0)
Forcing the product code to be set solved the issue I had even though I never found out what was wrong with the FindRelatedProducts action not picking up both products.