SDutt
Posts: 18
Joined: Fri Oct 17, 2025 8:35 am

Setting environment variables based on user selection in dialog

Hello,

In our project, we would like to set some environment variables based on some user selections in the installer dialogs.

For example, I have a custom dialog where I have some checkboxes. The property names of the checkboxes are something like:

CHECKBOX_SEL1

CHECKBOX_SEL2, etc.

So, I have defined some environment variables in the "Environment" tab of our Advanced Installer project. The names of the environment variables are something like:

SELECTION1_ENABLED

SELECTION2_ENABLED, etc.

I would like to set the value of these environment variables to "true" or "false" based on the user selection of those checkboxes.

And in the value field of the environment variable Properties, I have set it to: [CHECKBOX_SEL1] and tried, but this did not work.
I also set the vale to [%CHECKBOX_SEL1], but this didn't work either.

Please let me know how to proceed.

Thanks in advance,
SDutt
Last edited by SDutt on Wed Nov 12, 2025 1:13 pm, edited 1 time in total.
SDutt
Posts: 18
Joined: Fri Oct 17, 2025 8:35 am

Re: Setting environment variables based on user selection in dialog

Hello,

Actually, if I set the Value of these check boxes to true in the dialog, then the environment variable is set correctly, but only if the check box is selected during the installation.

If the user unchecks the checkboxes, the value is not set to false in the environment variable. In fact, the environment variable is not even set, and does not appear in the environment variables.

I would like to set these environment variables to true or false, based on the user selection of the checkboxes. Please let me know.

Thanks,
SDutt
Catalin
Posts: 7717
Joined: Wed Jun 13, 2018 7:49 am

Re: Setting environment variables based on user selection in dialog

Hello SDutt,

That happens because, by default, a property that does not have a value does not exist. This is not like a variable that is empty. This is the reason why the env variable is not even created.

To overcome this, we have to proceed like this:

1. set the default value to "true" of the checkbox
Screenshot_84.png
Screenshot_84.png (2.9 KiB) Viewed 9693 times
2. in the dialog where you select the checkbox, we need to have a "Set property" custom action scheduled as a published event - for example, we can set it on the "Next" button
Screenshot_85.png
Screenshot_85.png (52.63 KiB) Viewed 9693 times

This event will change the value of CHECKBOX_1_PROP to false in case it the property is empty (the checkbox is not checked).

Hope this helps! :)

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

Return to “Building Installers”