How to install feature based on the property set in custom action?

Too late to test all of this, but here goes with some information. I will check back tomorrow. Essentially I think the problem is your custom action sequencing. Try before Costing.

Some things to consider:

  • Custom action sequencing: you need to sequence your custom action right and it needs to be present in both silent and interactive installation modes.
    • Did you try to sequence the set property custom action before CostInitialize? You state you set it before InstallInitialize, but try it before CostInitialize instead (you might have tried).
    • And did you remember to insert this custom action in the InstallUISequence as well as the InstallExecuteSequence? You need to insert in both sequences in case the setup runs in silent mode. Before CostInitialize in both sequences I believe.
  • Feature Level: manipulating features via the feature level and INSTALLLEVEL is just one way to do feature control, you can also set features via the command line or using a custom action.
    • Setting a feature level to 0 should hide the feature from view in the setup’s custom dialog.
    • Setting a feature level higher than the setup’s INSTALLLEVEL will deselect the feature from installation.
    • And the other way around setting a feature level lower or equal to the setup’s INSTALLLEVEL will select the feature for installation.
    • The conditional syntax allowed is quite flexible, and could provide the functionality you need outright – but I have never used them properly. Here is an example from the Installshield forum.
  • ADDLOCAL & REMOVE: you can manipulate the feature selection by changing the values of the ADDLOCAL and REMOVE properties from a custom action (technically also REINSTALL and ADVERTISE) – and these properties can be set via the command line as well.
  • Win32: you can also use the Win32 functions MsiGetFeatureState and MsiSetFeatureState – from a C++ custom action – to set feature selection.

Frankly it is a bit mad the whole thing. Also keep in mind that there are feature action states (what is going to happen to a feature) and feature installed states (what state it is in). The Win32 function documentation should explain.


Cross-linking for easy retrieval:

Leave a Comment