cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sharon
Level 5

ADDLOCAL and feature condition evaluation

Hi all,

I have multuple features in a basic msi project.
one of them needs to be disabled on full UI and enabled only on SILENT mode using a "secret" property. meaning, that even if the user passes the feature in ADDLOCAL list, it should not be installed unless the property was set as well in command line.

I tried adding a feature condition using a new property, and passing the property before ADDLOCAL on cmd.
Unfortunately, as far as I can see, Feature conditions are evaluated only if ADDLOCAL is not set. Therefore, when not including the feature on ADDLOCAL with the rest of the required features, the feature condition does not get evaluated and the feature does not get installed. when including it on ADDLOCAL - it gets installed without checking the condition.

I have been struggling with this a lot,
would appreciate your help.
Thanks,
Sharon.
Labels (1)
0 Kudos
(1) Reply
enanrum
Level 9

Create a CA and have a condition if running silent to run it. You can basically go through your features and re-add them to ADDLOCAL and REMOVE checking their FeatureState to see if it is already installed:

[HTML]
myList = ListCreate(STRINGLIST);
ListAddString(listID,"Feature1", AFTER);
etc...

nResult = ListGetFirstString(myList,featureName);
while (nResult != END_OF_LIST)
MsiGetFeatureState (hMSI, featureName, nvInstallState, nvActionState);
if nvInstallState = INSTALLSTATE_LOCAL then
// add to Addlocal flag
else
if secretProperty = OK then
Addlocalflag=true;
else
Addlocalflag=false;
endif;
endif;

if AddLocal then
if strAddlocal = "" then
strAddlocal = featureName;
else
strAddlocal = strAddlocal + "," + featureName;
endif;
else
if strRemoveFlag = "" then
strRemove = featureName;
else
strRemove = strRemove + "," + featureName;
endif;
endif;

nResult = ListGetFirstString(myList,featureName);
endwhile;

MsiSetProperty(hMSI, "ADDLOCAL", strAddlocal );
MsiSetProperty(hMSI, "REMOVE", strRemove );

endif;[/HTML]

Or if you know what features are to be installed - just add them directly to the ADDLOCAL and REMOVE variables.
0 Kudos