Warning!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 "Finish Execution" action group
  • set the "Working Dir" field to SystemFolder
  • set the "Full Path" field to [SystemFolder]msiexec.exe /x GUID /qb, where GUID is the Product Code of the package you want to uninstall
  • in the "Execution Properties" section, select the "Asynchronous Execution, do not wait for return" option
  • in the "Expression" field of the "Execution Condition" section set this condition: REMOVE="ALL"

NoteThe 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.

NoteIf the product you want to remove is not MSI-based, you can use a "Launch file or open URL" 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) = "[1]"
	      record.StringData(1) = CStr(msg)
	      ans=Session.Message(msiMessageTypeUser + vbYesNo, record)
	      If ans=msiMessageStatusYes Then
	      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: