Partager via


Any tips on getting the cancel button working for a deferred custom action?

Question

Any tips on getting the cancel button working for a deferred custom action?

During our MSI uninstallation (full GUI mode), at the beginning of the uninstallation we call a deferred CA. When this CA is executing, if the user clicks the cancel button, the windows installer will pop up the dialog asking you if you want to really exit the (un)installation or resume. At this stage, if I click to cancel the installation, nothing happens, and after our CA completes and file removal starts, clicking on the cancel button again throughout the rest of the uninstallation had absolutely no effect… I checked our MSI package’s cancel dialog, the two buttons are returning the right events (Return, and Exit events).

My questions are

  1. Do I need to do anything in our custom action functions to handle the exit event?
  2. Or is this handled by the windows installer?
  3. If I need to handle this myself – what do I need to do?
  4. Also, why does the cancel button not work when it’s pressed again after my custom action has returned?

Answer

You should look at the return values from various MSI functions (such as MsiProcessMessage, you are sending progress messages aren't you?). You'll notice that there are return values that indicate the user has clicked cancel while your action was running. If this occurs, your CustomAction should bail and return ERROR_INSTALL_USEREXIT.

You can see examples how this is done in the WiX serverca CustomActions... they use the core OcaXXX functions that wrap the Msi APIs to correctly handle the user cancel case.

Related context:

Confirmation

Thanks, that suggestion worked, I put in code to trap return codes from MsiProcessMessage() in the custom actions and return the userexit error if MsiProcessMessage() returned IDCANCEL.

Content credit also belongs to

[Author: Robert Flaming]

This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at https://www.microsoft.com/info/cpyright.htm.