Zsolt Kollarits
Posts: 405
Joined: Fri May 29, 2015 10:36 am

Forcing a feature to be uninstalled

Dear Advanced Installer,

We have a feature which is being discontinued, so we would like to
1. Remove it from the features list (Organization tab) -> it means customers won't be able to deselect it from Control Panel -> <our product> -> Change dialog
2. So it needs to be removed from the PC, and all belonging files. Can we force this removal somehow, e.g. when we release a dedicated version of our product without this deprecated feature, the upgrade mechanism should remove this old feature.

Best regards,
Zsolt
Liviu
Posts: 1395
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Forcing a feature to be uninstalled

Hello Zsolt,

Sorry for the delayed reply on this.

If you release this as a major upgrade, then you can remove the deprecated feature from the Organization page in the new version of the project. During the upgrade, the old version will be uninstalled and replaced by the new one, so the components/files that belonged only to the removed feature should be removed from the machine as part of the old product uninstall.

For this scenario, we recommend using the upgrade option to uninstall the old version first and then install the new version, as this is safer when the feature structure changes.

Please also make sure that:
  • The files that belong to the deprecated feature are not shared with other features/components.
  • The related components are not marked as permanent or configured in a way that prevents removal.
  • Files created later by the application, or files not originally installed by the MSI, will not be removed automatically by Windows Installer. For such extra/generated files, you can add File Removal or Folder Removal operations in the Files and Folders page.
Please let us know if you encounter any issues related to this matter.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 405
Joined: Fri May 29, 2015 10:36 am

Re: Forcing a feature to be uninstalled

Hi Liviu,

Thank you for your answer. I will remove the old feature from our setup, which means during an upgrade in the first uninstall phase the old feature will be removed.

We added our new feature which is kind of a "newer version" of the old feature, but it's a complately separate feature. How could we make sure that the new feature is being installed on the end PC only if the old feature was also installed on the PC? So if a user had that old feature, he must get the new one too out of the box.

Note: for both feature we have an install and uninstall custom action too, as we need to run some custom code too to be able to install or uninstall this special feature. Adding some regkeys and files is not enough. I'm wondering which custom action to keep, and what would be the proper order. I think I need to keep the "uninstall of old feature" custom action even in our latest product to be able to properly uninstall the old feature. Or an an upgrade scenario the old product will be uninstall, and during uninstall it will delete all of the files + will run the uninstall custom action too.

Main question is, how to conditinally install the new feature based on the existence of the old?

Best regards,
Zsolt
Liviu
Posts: 1395
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: Forcing a feature to be uninstalled

Hello Zsolt,

Yes, your understanding is correct regarding the uninstall part.

If you use a major upgrade configured to uninstall the old version first, the old product will be uninstalled during the upgrade. This means the old feature’s resources should be removed by the old package, and the old feature’s uninstall custom action should also run from the old package, as long as it is correctly conditioned for uninstall.

Regarding the main question, how to install the new feature only if the old feature was installed, the recommended approach is to detect the old feature before the old product is removed, store the result in a public property, and use that property to condition the new feature.

You need to identify something that exists only when the old feature is installed:
  • a registry value,
  • a file,
  • a folder,
  • or another reliable marker created by that old feature.
In the new project, create a search for that resource, for example:

OLD_FEATURE_INSTALLED

Then, use this property to condition the new feature from the Organization page.

Hope this helps!

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”