cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reureu
Level 10

Setting a feature as "Required" programmatically

Hi,

I have a feature whose "Required" setting is set to No.

  • If certain conditions are satisfied on the target system, I would like this feature to be required, so that the user cannot deselect it.
  • If these conditions are not satisfied on the target system, the end user can choose whether he wants to install the feature or not.


I have investigated a bit, and I have found that this "Required" setting corresponds to the bit 4 (LSB is bit 0) of the feature attribute (decimal value of 16), which corresponds to the msidbFeatureAttributesUIDisallowAbsent flag.

I thought the MsiSetFeatureAttributes function would do the job.
But I don't think I can use it to set the msidbFeatureAttributesUIDisallowAbsent flag, can I?

The funny thing is: if I set the feature "Required" setting to "Yes", and then use MsiSetFeatureAttributes, the feature is no longer required at installation.

So, the MsiSetFeatureAttributes can clear this msidbFeatureAttributesUIDisallowAbsent flag, but cannot set it. Is that right?
Labels (1)
0 Kudos
(1) Reply
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

The MSDN documentation does not zindicate that msidbFeatureAttributesUIDisallowAbsent can be passed to MsiSetFeatureAttributes. This would seem to imply that changing this attribute at runtime with this API is not supported. Unfortunately, since this is a function implemented by Windows Installer, we don't have any additional information on how it works besides what is documented on MSDN.
0 Kudos