gvnsandeep
Posts: 7
Joined: Tue Aug 11, 2020 3:23 pm

How to disable a feature at run time?

Hi,

Can some one help me with a project sample on "How to disable a feature at run time based on the supplied license file"?
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: How to disable a feature at run time?

Hello Sandeep and welcome to our forums,

I am not quite sure I understand your scenario here.

In order for me to assist, could you please give me some more details about what you want to achieve (maybe exemplify)?

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
gvnsandeep
Posts: 7
Joined: Tue Aug 11, 2020 3:23 pm

Re: How to disable a feature at run time?

Hi Catalin,

Here is my scenario. I will be creating an installer with the following features.

1. Feature 1
2. Feature 2
3. Feature 3

Once the installer gets started, I will ask the user to upload a license file, once after the file gets uploaded, I should be able to decode the file and disable the features that are not available in the license.file.

LicenseFile:
<LICENSEFILE>
<LICENSE>FEATURE1</LICENSE>
<LICENSE>FEATURE2</LICENSE>
</LICENSEFILE>

So, if a user uploads the above license file, I should be displaying only Feature 1 and Feature 2, Feature 3 should be disabled.

Could you please help me "How do I achieve this functionality in advanced installer". Please attach a sample to this thread.
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: How to disable a feature at run time?

Hello,

Unfortunately, we do not have predefined support for this task.

You can, however, try to achieve this by using a custom action.

For instance, let's consider we have 3 features, i.e.:

Feature1
Feature2
Feature3

For each of these features, we will have their "Installation Behavior" ("Organization" page --> your feature) set to "Installed".

We will need a property to condition the "Disabled if" field for each of our features. For instance, the "Disabled if" field for the first feature could look like this:

Code: Select all

FEATURE_1_PRESENT = "false"
Now, the custom action could look something as this:

Code: Select all

read the license file

if (feature1 is found)

set FEATURE_1_PRESENT to "true"

else set FEATURE_1_PRESENT to "false"
Now, the above check should be done for each feature and another property should be used. For instance, for Feature2 we will use the FEATURE_2_PRESENT property and so on.

For more details about setting a property from within a custom action, please have a look over our "How to set an installer property using custom actions" article.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
gvnsandeep
Posts: 7
Joined: Tue Aug 11, 2020 3:23 pm

Re: How to disable a feature at run time?

Hi Catalin,

I have tried what you said... Like created an Installer Property in the name of DISABLE_FEATURE_1 and set the value by default to false in Install Parameters section, and have updated the condition Disabled If property to DISABLE_FEATURE_1 <> "false". Created a C# DLL to set the installer property to true and created a custom action on the same.

However the feature is not getting disabled when I run the installer.

Please find the attached project, and let me know where I am going wrong.

Note:

1. If I make use of UpdateFeaturesInstallState custom action the option is getting de-selected, however it is not getting disabled.

2. The same happens even if I go for a powershell script custom action along with UpdateFeaturesInstallState the option is getting de-selected, however it is not getting disabled.

2. If I try setting the Features Property to Disabled using the code below in c# - The installer crashes.

session.Features["Feature2"].RequestState = InstallState.NotUsed;
Attachments
Features POC.aip
(20.75 KiB) Downloaded 206 times
gvnsandeep
Posts: 7
Joined: Tue Aug 11, 2020 3:23 pm

Re: How to disable a feature at run time?

Hi Catalin,

Could you please help me with the problem what I am facing?

Regards,

Sandeep
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: How to disable a feature at run time?

Hello Sandeep,

Thank you for your followup on this.

I have done some testing and I was indeed able to replicate the behavior.

This looks to be an issue in what regards our "OptionalFeatsDlg" dialog.

I will forward this issue to our development team so it can be fixed in a future version of Advanced Installer.

Until then, could you please try to use the "ConfigureDlg" dialog instead? Simply delete the "OptionalFeatsDlg" dialog and then add the "ConfigureDlg" dialog.

The feature should be disabled as expected on that dialog.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Catalin
Posts: 6585
Joined: Wed Jun 13, 2018 7:49 am

Re: How to disable a feature at run time?

Hello Sandeep,

This issue has been fixed in version 17.6 of Advanced Installer, released on October 22nd, 2020.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”