frankb
Posts: 6
Joined: Fri Mar 26, 2010 12:55 am

Display dialog on uninstall from Control Panel

When uninstalling the application from Add/Remove Programs in the Control Panel, is there anything I can do in AI to display a dialog (or even just a Yes/No Message Box) that would either cancel the uninstall or proceed based on which button the user clicked on the dialog? This dialog would display prior to the standard "Are you sure you want to remove MyApp from your computer?" that the Control Panel presents. So basically the user would be responding to two prompts before the uninstall began.

I recall having seen before an app-specific dialog when removing a program in Control Panel, so that must be possible, but wondering if AI supports that.

Thank you
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Displaying a message box

Hello,

You can use the Message Box custom action conditioned by:

Code: Select all

REMOVE = "ALL"
to condition a message box to display.
Condition a vbscript to return an error code that will then break the install. In the condition, use the property returned by the message box custom action.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
frankb
Posts: 6
Joined: Fri Mar 26, 2010 12:55 am

Re: Display dialog on uninstall from Control Panel

Hello Gabriel,

I'm sure there's an easy answer to this, but I must be overlooking something.

I created a Custom Action under InstallExecuteSequence > Uninstall to display a MessageBox conditioned on REMOVE="ALL" as you indicated. So far, so good.

Underneath that I created another custom action to run a vbscript to return an error code to "break the install" as you indicated. This custom action is conditioned on the Remove All as well as the property BTN_PRESSED="IDNO". The idea is that if one button is pressed (IDYES) this custom action is not executed; if it is IDNO, then it isn't. However, no matter which button is clicked, the uninstall proceeds. I've debugged by changing this custom action to yet a different MsgBox, and it does prove that the logic and the conditioning of the custom action is correct (shows the new MsgBox when "No" is pressed, and doesn't when "Yes" is).

So the problem is with my vbscript, or the way it executes, or what it needs to return. When you say it shour return an error code, is there a specific value that it needs to return? I tried 1 and 0 and it doesn't make a difference. Is there a specific configuration of the vbscript custom action properties that need to be selected? I used Synchronous execution, check return code, along with Immediate execution. Played around with changing those to no avail. It's as if running the script does nothing to stop/abort the install.

Any thoughts? If there is a specific script that should be used (and I imagine it would be very short, since at that point we just want to abort the uninstall) can you give me an example?

Thanks
Frank
frankb
Posts: 6
Joined: Fri Mar 26, 2010 12:55 am

Re: Display dialog on uninstall from Control Panel

Hello Gabriel,

Following-up on my latest post - I don't know why I didn't try to return -1 from the script, but in any event, that does cancel the install. However, a "Fatal error" message then is displayed, which I'm sure is because of the script returning an error (-1). Since the uninstall is being stopped as a result of the user responding to a Yes/No button in the MessageBox I inserted, I need to have a graceful cancellation, and not something that appears there was a serious error somewhere.

So... Is there something I need to do differently to avoid that message? If not, is there a property that contains the text for that "fatal error" where I could modify what it says? If nothing else, is there a property where I can modify the text of the Control Panel's Uninstall standard message, where it asks if you're sure you want to remove MyApp?

Thanks for your continuing assistance with this.

Frank
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Display dialog on uninstall from Control Panel

Hello,

You will want to return 2 which is the error code for ERROR_INSTALL_USEREXIT as specified here:
custom action return codes

This will terminate the install process without an error.

Let me know if this helped.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
frankb
Posts: 6
Joined: Fri Mar 26, 2010 12:55 am

Re: Display dialog on uninstall from Control Panel

Thank you, that worked!

Return to “Common Problems”