cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
vickenk
Level 4

Check if a feature is selected

How can I check if a specific feature is selected by the user in custom setup? I want to execute a custom action during installation if a particular feature is selected . Thanks.
Labels (1)
0 Kudos
(5) Replies
jonathanqis
Level 6

test on

if (FeatureIsItemSelected ( MEDIA, "MainFeature\\subFeature" )) then

or use

FeatureGetData (MEDIA, "Feature2", feature_FIELD_SELECTED, nvResult, svResult)
N.B. see the FeatureGetData sample.
0 Kudos
JohnBrent
Level 5

(note: i'm still a complete noob)

i have 3 features, each of which have no sub-features

displayed in the tree as F1, F2, F3 ~ displayed in the IS dialog as Feature1, etc

i have tried both methods you suggest, using both "F1" and "Feature1"

result is consistently "not selected" regardless of actual selected status

can't figure out what i'm doing wrong 😞

any suggestions?
0 Kudos
JohnBrent
Level 5

i have this running as Immediate / After Filecost - why? i have no idea

should this check be done at some other point?

thanks
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

The Feature* InstallScript functions only work with InstallScript and InstallScript MSI projects. If you are calling these functions from an InstallScript custom action in Basic MSI projects (or an InstallScript custom action in InstallScript MSI projects) the functions will not provide an indication of the state of an MSI feature.

The simplest solution to running or not running a custom action based on the selection of a feature would be to use a condition on the custom action. The action state of a feature can be used in a condition such as the following:
&FeatureName=3

More information on conditional statements can be found in:
Conditional Statement Syntax
Examples of Conditional Statement Syntax

Note that this assumes the custom action is sequenced after feature selection occurs. If this action will modify any system state, it should be sequenced in the execute sequence as a deferred action (deferred in system context if it needs admin privileges when the MSI is run elevated).
0 Kudos
JohnBrent
Level 5

Josh - thanks for the explanation - wondered what the heck was going on ...

i'd seen the "&featurename" mentioned in other threads but didnt know where/how to use it - now that i know, my conditions function properly ~ yay!
0 Kudos