This is not recommended because it will make your installation package remove other applications.
If your installation package includes some MSI-based prerequisites, you may want to remove them when your application is uninstalled. For this you can use a custom action:
- go to the Custom Actions page
- add a new "Launch EXE with working directory" custom action after "Install Execution Stage" -> "Finish Execution" action group
- set the "Working directory" field to SystemFolder
- set the "File path" field to msiexec.exe
- set the "Command line" field to /x GUID /qb, where GUID is the Product Code of the package you want to uninstall
- in the "Execution Options" section uncheck the "Wait for custom action to finish before proceeding" and "Wait for return code at the end of the sequence" options
- in the "Condition" field of the "Execution Stage Condition" section set this condition: REMOVE="ALL"
The custom action is launched asynchronously because two MSI-based installations cannot run at the same time. This way the custom action runs right after the main install process is finished.
If the product you want to remove is not MSI-based, you can use a "Launch file" custom action to launch the Uninstaller of the product (if it has one).
Since we don't want to uninstall applications on the target machine without the user's permission, you can use a custom action which prompts the user. The custom action can look like this:
Function Ask MsiMsgBox("Do you want to uninstall the prerequisites?") End Function Function MsiMsgBox(msg) Const msiMessageTypeUser = &H03000000 Const msiMessageStatusYes = 6 Set record = Session.Installer.CreateRecord(1) record.StringData(0) = "" record.StringData(1) = CStr(msg) ans=Session.Message(msiMessageTypeUser + vbYesNo, record) If ans=msiMessageStatusYes Then Session.Property("UNINSTALL_PREREQ")="YES" Else Session.Property("UNINSTALL_PREREQ")="NO" End If End Function
This VBScript custom action shows a message box which asks the user about uninstalling the prerequisites. Also, it sets the UNINSTALL_PREREQ property to the answer given by the user. You can schedule this custom action under the "Install Execution Stage" -> "Finish Execution" action group as Immediate. Also, the condition of the custom action should now be:
REMOVE="ALL" AND UNINSTALL_PREREQ="YES"