I am working on a project that uses WIX to install an application. One of the requirements is to remove the old version before installing the current one. The old version is not MSI-based, it is created with SetupApi (which relies on inf files).
I figured this can be achieved with a custom action, the logic is as follows:
My questions are:
In case you're interested, here are the code snippets that do what I described above:
<Property Id="ANCIENTVERSION">
<RegistrySearch Id="RegistrySearchAncientVersion" Type="raw"
Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Program"
Name="UninstallString" />
</Property>
<CustomAction Id="removeAncientVersion"
Directory="SystemFolder"
<!--ExeCommand="[ANCIENTVERSION]" regular uninstall-->
ExeCommand="[ANCIENTVERSION],3" <!--silent uninstall-->
Execute="immediate"
Return="check"/>
<InstallExecuteSequence>
<Custom Action='removeAncientVersion' After='InstallValidate'>ANCIENTVERSION</Custom>
</InstallExecuteSequence>
After some research I found that in order to run a silent uninstall, one needs to add ",3" to the end of the UninstallString command line. I tested it and it works:
Regular uninstall
RunDll32 advpack.dll,LaunchINFSection C:\PROGRA~1\PROGRAM\file.inf, DefaultUninstall
Silent uninstall
RunDll32 advpack.dll,LaunchINFSection C:\PROGRA~1\PROGRAM\file.inf, DefaultUninstall,3
As for the first question - since the uninstallation mechanism is the equivalent of clicking "Uninstall" in Add/Remove programs, I believe it can't get any cleaner/better than that.