stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Delete registry key only on actual uninstall

I have a registry key that I want deleted, regardless of its contents, on uninstall, but not on upgrade.

Currently, when I select "Delete (if present) at uninstall" from the key's properties, it deletes the key both upon upgrade and uninstall.

This key contains my product's activation key, so I want to remove it only with the user is actually uninstalling. When they are upgrading to a new version, I want to leave the key intact.

How can I do this with AI?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Delete registry key only on actual uninstall

Hi,

Unfortunately an upgrade will completely uninstall the previous version. However, you can try using a custom action which creates a backup of the entry before the upgrade and restores it after the upgrade. Please note that the User Guide contains the Preserve registry key at install how-to which may help you.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Delete registry key only on actual uninstall

Sorry if I'm in denial here. I want to remove my product's unlock code upon user-initiated uninstall, but not upon upgrade. I don't want them to have to reactivate after upgrade.

Thanks for the suggestion to backup the key. But I don't want to leave an unlock code on the machine after uninstall.

Is there no possible way to differentiate a user-initiated uninstall from what happens during upgrade?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Delete registry key only on actual uninstall

Hi,

An upgrade will automatically uninstall the old version, including the registry entry you need to keep. If you use the solution I mentioned, you can condition the backup and restore custom actions to run only during an upgrade. For example, you can use the condition:

Code: Select all

REMOVE = "ALL" AND OLDPRODUCTS
This way the registry entry will be backed up and restored only if an older version is found. Please note that this approach is designed for the new version of the package. Therefore, the backup is performed when the new version is installed.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Delete registry key only on actual uninstall

I think there's a misunderstanding - my fault.

What I want to keep is a new registry value placed by my app in a registry key created by the installer. The default behavior upon upgrade (assuming I do not check "Delete (if present) at uninstall") is to leave my value (and the installer-created parent key) intact, since the value was not created by installer.

However, I have found that choosing "Delete (if present) at uninstall" on the key will delete it even if it contains the app-created value. This is the behavior I want, but only on uninstall.

Now that that is clarified, is it possible to create a custom action that runs late in the sequence, conditioned on "REMOVE = 'ALL' AND NOT OLDPRODUCTS", that runs a vbs script to delete my app-created registry value? That is, will "NOT OLDPRODUCTS" evaluate TRUE if evaluated late in a full uninstall?
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Delete registry key only on actual uninstall

This appears to work in my testing:

I've attached your script for deleting a registry key to the Begin event, and set the condition to (REMOVE="ALL" AND (NOT UPGRADINGPRODUCTCODE)).

It's producing the outcome I wanted; a) key is deleted on uninstall, say, from Add/Remove Programs. b) key is not deleted on automatic upgrade

Does this make sense or is there a gotcha from this approach that I'm missing?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Delete registry key only on actual uninstall

Hi,

Since the entry is created by the application and not by the package, using a custom action to remove it is the correct approach.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Delete registry key only on actual uninstall

Thanks for your help on this.
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Delete registry key only on actual uninstall

I've just noticed that my approach is working when the app is uninstalled via Add/Remove Programs, but not when I run the installer and select 'Remove'.

My script appears under InstallExecuteSequence\Begin, and the condition is (REMOVE="ALL" AND (NOT UPGRADINGPRODUCTCODE)).

Any idea why the script does not execute when performing a 'Remove' from the installer - and how to fix it?
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Delete registry key only on actual uninstall

Hi,

I'm not sure why you are encountering this behavior. If the custom action runs in "InstallExecuteSequence", it shouldn't matter how the uninstall is launched. Can you please send us the AIP file you are using to support at advancedinstaller dot com so we can investigate it? Also, please attach a verbose log of the uninstall process.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
stevefal
Posts: 119
Joined: Wed Sep 03, 2008 9:02 pm
Location: Washington USA
Contact: Website

Re: Delete registry key only on actual uninstall

I sent a sample project demonstrating the issue.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Delete registry key only on actual uninstall

Hi,

It seems that when using an UI the REMOVE property is set to "ALL" only after the "InstallExecuteSequence" -> "InstallValidate" standard action. In this case a solution is to move your custom action after "InstallValidate".

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”