superfun
Posts: 4
Joined: Thu Jun 26, 2008 4:42 pm

Custom Action that Gracefully Aborts Uninstall

This may be a simple problem. I'd like to run a custom action during uninstall that checks a few things and then asks the user if they'd like to continue with the uninstall or cancel. I can get this to work except that whenever the user cancels they get the message:
"There is a problem with this Windows Installer package. A program run as part of the setup did not finish as expected. Contact your support personnel or package vendor."
Followed by:
Fatal error during installation.
My custom action is an EXE. It runs under the Begin action at the condition (REMOVE="ALL" AND (NOT UPGRADINGPRODUCTCODE)). How can I gracefully abort the uninstall?

(I've tried searching the forums on this but a search for "custom action abort uninstall error message" ignores all of the words except abort.)
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom Action that Gracefully Aborts Uninstall

Hi,

This happens because of the return code of the custom action set when the user clicks the "Cancel" button. Note that the return code of a custom action must be 0 for success or one of the other predefined values for a user-friendly behavior (a custom return code is seen as failure).

For example, your custom action should return 0 for the "Continue" button and 1602 for the "Cancel" button.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
superfun
Posts: 4
Joined: Thu Jun 26, 2008 4:42 pm

Re: Custom Action that Gracefully Aborts Uninstall

I have tried different return values suggested by the MS documentation (ERROR_INSTALL_USEREXIT) but all of the non-zero return values display the same error message. The continue/cancel goes through so the return value isn't being entirely ignored.

What I'm reading in other places suggests that this isn't possible with an EXE custom action but is with a DLL custom action. It seems that EXE custom actions can't supply a reason for failure.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Custom Action that Gracefully Aborts Uninstall

Hi,
It seems that EXE custom actions can't supply a reason for failure.
Yes, this is true. Also, EXE custom actions cannot access installer properties, therefore the install process cannot be affected.
Please note that we have a sample DLL custom action which may help you create the custom action you need.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
superfun
Posts: 4
Joined: Thu Jun 26, 2008 4:42 pm

Re: Custom Action that Gracefully Aborts Uninstall

Thank you for the sample.

I have created a DLL custom action and it works beautifully. It returns 0 to continue the uninstall and 1602 to abort. There is no nasty error message about failure.
Uria
Posts: 21
Joined: Tue Mar 03, 2009 8:47 am

Re: Custom Action that Gracefully Aborts Uninstall

Hi,

Can I produce the same result with a .Net installer class custom action?
I want to be able to abort an installation based on user decision in a dialog displayed by the custom action.

Thanks!

Return to “Common Problems”