We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Disabling features based off a serial number

Hello!

Scenario:
The user enters a serial number in a dialog. Based on that serial number, I want to disable a feature. That is, I want to prevent the feature from being installed, and I want to prevent the feature from being displayed in CustomizeDlg.

Implementation:
I have a custom action that analyzes the serial number and sets properties based on the results. For example, if the serial number does not allow "FeatureA" to be installed, it will set the property INSTALL_FEATURE_A=0.


Now, I'm not sure what the proper way to handle this is. I've tried using the feature's "Installation Behaviour" properties by setting "Disabled if:" to INSTALL_FEATURE_A=0. However, the issue here is the feature can still be seen (and enabled by the user) in CustomizeDlg. It appears in the feature list with an X icon. The conclusion I came to (after reading this: http://198.154.230.79/forums/viewtopic.php?f=2&t=1162) is that you cannot disable a feature (hide it in CustomizeDlg) after CostFinalize. Since the serial number is analyzed (and the INSTALL_FEATURE_A property set) after CostFinalize, I don't believe I can use the "Disabled if:" field of the feature.


So, is there a "standard" way to handle this scenario? The only solution I can think of is to write a custom action that disables the feature by modifying the in-memory MSI (also discussed here: http://198.154.230.79/forums/viewtopic.php?f=2&t=1162). I just wanted to check if there was a better way to handle this before I went down this road.


Thanks.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Disabling features based off a serial number

Hi,
I have a custom action that analyzes the serial number and sets properties based on the results. For example, if the serial number does not allow "FeatureA" to be installed, it will set the property INSTALL_FEATURE_A=0.
In this case, you can execute your custom action on the "Next" button of the dialog where the serial number is introduced by the user and use the INSTALL_FEATURE_A = "0" condition in the "Disabled if" field of the "FeatureA" feature.

If it still does not work, you can try to add the "Update Feature's Install State" predefined custom action to be executed as an "Init Event" on the dialog that displays the list with the features.

Let us know if this helped, otherwise give us more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Re: Disabling features based off a serial number

Sorry, I should have specified. I am indeed calling my serial number analyzer custom action on the "Next" button of the serial number dialog, and the INSTALL_FEATURE_A property is being set at this time. I have also added an "Update Feature's Install State" custom action to the "Init Event" of the "Choose Setup Type" dialog. The issue can be seen in the attached screenshot.

The feature is being de-selected, but the user can still see the feature and re-enable it (though, the feature still won't be installed). So, it's like the feature is being set to "Not installed", instead of being completely "Disabled". I think this is because of the CostFinalize issue.
Attachments
Capture.PNG
Capture.PNG (11.26 KiB) Viewed 3980 times
codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Re: Disabling features based off a serial number

After some more research, I've come to the following conclusion ...

There are three potential ways to handle the above scenario:
1 - Modify the in-memory MSI using a custom action.
2 - Use the "Disabled if" condition and call CostFinalize (through a custom action) after analyzing the serial number and setting your property that the condition is based on (INSTALL_FEATURE_A)
3 - Use a custom CustomizeDlg.

None of these options are perfect. From testing, I know that options one and two will work. The limitation of option two, is that you cannot re-enable a feature after it has been disabled. So, basically, you have to prevent the user from entering a new key after they have already entered one (disable the following dialog's back button).

I'll probably go with option two, as it seems less "messy" than option one.


Thanks.

Return to “Building Installers”