condition to disable a feature - Advanced Installer Community
xdunat
Posts: 4
Joined: Wed Mar 08, 2023 4:16 pm

condition to disable a feature

Hello,

I have a problem disabling a feature based on the presence of a registry key.
First I create a CITRIX_HKLM property with the value 0. Then I create a "new extended search" which I name CITRIX_HKLM. For criteria I put "Registry key exists", and I enter my registry key.

In "Installation Behavoir" of my feature, in "disabled if:", whether I put CITRIX_HKLM = "0" or CITRIX_HKLM = 0, my feature is not displayed in ConfigureDlg.

However in the logs I see that CITRIX_HKLM goes to 1 :
PROPERTY CHANGE: Modifying CITRIX_HKLM property. Its current value is '0'. Its new value: '1'

Regards
Liviu
Posts: 1419
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: condition to disable a feature

Hello and welcome to our forums,

Please note that this is the default behaviour when using the "Disabled" option.

If you select the "Disabled" option the feature will be disabled. The user cannot change its installation state. It will not be displayed during the installation.

If you want to show this feature on your dialog and disabled it (so that the user cannot change it), you need to implement your own feature selection dialog. This way, you can condition each Checkbox based on the search result.

Please take a look at our How to show a custom feature selection dialog article.

Hope this helps! If you have any other questions, please don’t hesitate to contact us.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
xdunat
Posts: 4
Joined: Wed Mar 08, 2023 4:16 pm

Re: condition to disable a feature

Hello,

Thank you for your reply.

The behaviour is "Installed". I want to disable if a registry key is not present. I put a condition to "disable if" (Install level 0).

Besides, if I put a value that cannot match, for example : CITRIX_HKLM = "notdisplayed"
My feature is not disabled, and the user may choose to install the feature.

Should I still create my own selection dialog ?
Liviu
Posts: 1419
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: condition to disable a feature

Hello,

You can achieve this with the search you implemented.

Please see the example below.

Let's say we do not want to display a feature if the Java JDK 19.0.1 registry key is not found on the target machine.

1. We create the following search:
search.png
search.png (32.93 KiB) Viewed 4410 times

The RESULT_PROPERTY property will return the value of the JavaHome key.

2. On the Organization page we can use the "NOT RESULT_PROPERTY" condition on the "Disabled if" option.
feature.png
feature.png (77.85 KiB) Viewed 4410 times

Now the Feature2 will only be displayed on the dialog if the search is successful. Otherwise, if the registry key is not present, then the feature will not be displayed.

Let me know if that helped you.

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
xdunat
Posts: 4
Joined: Wed Mar 08, 2023 4:16 pm

Re: condition to disable a feature

I don't understand (perhaps a bug with version 19.8.1).

For the second part, I copied "installation behavior". For one feature I set to "disable if": NOT RESULT_PROPERTY and for the second: RESULT_PROPERTY. Now both are not showing.
search.png
search.png (13.32 KiB) Viewed 4406 times
driver.png
driver.png (32.69 KiB) Viewed 4406 times
citrix.png
citrix.png (39.34 KiB) Viewed 4406 times
If I display CITRIX HKLM in a custom window I see the value of the key.
Liviu
Posts: 1419
Joined: Tue Jul 13, 2021 11:29 am
Contact: Website

Re: condition to disable a feature

Hello,

I'm not sure why this happens.

Can you please send us the .AIP (setup project) file by email to support at advancedinstaller dot com so we can further test and investigate this?

Best regards,
Liviu
________________________________________
Liviu Sandu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”