1
votes

I have a basic MSI setup created with Installshield 2012.

When uninstalling this setup, i have to check for a specific condition and depending on this condition i have to either keep or uninstall the files/folders/shortcuts of some components.

Right now i've set "Permanent=Yes" on these components and delete the files/folders/shortcuts in a managed assembly called from a custom action.

Is there a better way to do what i want?

1
Permanent is forever, so components marked as permanent are never removed. You might be able to combine this with conditional removal of the data installed by the component, but that's a messy proposition.Michael Urman
@MichaelUrman Right now I'm deleting the files from a custom action which calls function in a c# dll. But i hardcoded the filenames in the dll which is a bad thing. I didn't find a way to set "Permanent=No" from a custom action during runtime or call an Msi...-function to delete all files of a component.haide

1 Answers

0
votes

You should probably be thinking in terms of selecting or deselecting features rather than components. The Windows Installer model takes selected features and then installs the components needed by those features.

If the installation of these file/folders/shortcuts is conditional upon something, you should consider them to be the components belonging an optional feature. Then you could use MsiSetInstallLevel to set the appropriate installation level for the installation so that it does or does not install your optional feature depending upon a condition. The feature level is specified in the Feature table and processing the Condition Table can modify the level value of features .

Some of this is explained in the documentation: Working with Features and Components