“Hide” Features Based on ALLUSERS / MSIINSTALLPERUSER

只愿长相守 提交于 2019-12-02 04:11:06

Per-User Setups: I won't lie to you, I actively avoid this sort of setup. I find MSI's per-user installation constructs "not ideal". It relates to poor serviceability (upgrades, patching, etc...) and a number of other details. Some details mid-page here.

Some links for others who read this answer (I think you have read these):

Feature Conditions: With that said you can use feature conditions to unselect features based on whether a certain condition is true or false. You can even set the Level of a feature to 0 which will hide it from the GUI entirely during installation. You could try this. Please also read the linked answer below (bolded). It contains a better explanation of feature conditions.

I don't have time to test this, but here is a WiX mock-up that you can try:

<Feature Id="MyFeature" Level="1"> <!--Default to install feature-->

    <Condition Level="0"> <!--Do not install feature if condition is true-->
       ALLUSERS=2 OR MSIINSTALLPERUSER=1
    </Condition>

</Feature>

These answers might help you get an overview of this:


Hide Feature Testing: I will add a little snippet you can use to verify the operation of the feature hiding. It forces the condition in question to be true by setting it to 1 - as opposed to using a "real condition" that can be false unexpectedly.

<Feature Id="SupportingFiles" Title="SupportingFiles" Level="1">
   <Condition Level="0">1</Condition>
</Feature>

This should hide the SupportingFiles feature from view in the setup GUI, and it should also not install it. Please let me know if you see a different behavior.


Custom Actions: To interactively hide a feature based on changes done in the GUI, you can try to use custom actions to control the feature levels.

I am not sure this will work. I will test when I get the chance. Just adding that link for now.

UPDATE: I am unable to investigate this right now. I want to alert you to the possibility of adding temporary rows to the database during installation. Perhaps this is the way to go to hide the feature "interactively". I just don't know since I have never tried. Here is the first link I found on temporary records. And towards the bottom here are links. No guarantees.

Other than that I suppose you could use an external GUI launcher. I might comment on this later. I recently wrote about this issue (external GUI).


Some Further Links For Reference:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!