Kratzer
Posts: 66
Joined: Wed Apr 10, 2013 5:36 pm

Checkbox and setting property values

Wed Nov 14, 2018 1:50 pm

Hello AI Team,

I have a question about checkboxes. I've searched in the board and in the online help too, but didn't understand what to do...

We want to add a checkbox on one of the dialogs.

- a (global) property is set to value 1
- per default the checkbox should be checked and an associated property (the global one above) should have value 1. (or "1"?)
- when unchecking the Checkbox, property should have value 0.
- when checking the checkbox again --> property should get the value 1 again

The property is then used in conditions for installing features and executing custom Actions.

What has to be done?

Best regards
Bernd

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

Re: Checkbox and setting property values

Wed Nov 14, 2018 2:44 pm

Hello Bernd,

Let me try to explain how you can achieve this. First of all, a checkbox state is saved (stored) into a public property. If you add a checkbox on any of your dialogs and then press on it, on the right pane, under "Property" --> in the "Property name" field, you can see the property name. By default, a checkbox porperty name looks something like this: CHECKBOX_1_PROP, but you can change its name.

The checkbox can have two states:

- checked --> if the checkbox is checked, the value of its property is "CheckBox".

- not checked --> if the checkbox is not checked, the value of its property is "".

Now, let me try to explain how you can achieve what you want through an example:

- let's say you created a property in "Install Parameters" page having its name MY_PROP and its value of 1 (no quotes).

- after that, you added a checkbox on the "WelcomeDlg" having its property CHECKBOX_1_PROP

- and now, through the state of the checkbox, we want to set our earlier created property. To do so, please go on the dialog where the checkbox is located (in our example "WelcomeDlg"), click on the "Next" button and under "Published Events" tab, press the "New..." button to create an event as it follows:

(Set installer property)
- Property: MY_PROP
- Argument: 1
- Condition: press the "..." button and insert the following condition: CHECKBOX_1_PROP = "CheckBox"

Now that we have create the event that sets the property to "1" (without quotes) when the checkbox is checked, its time to set the property to "0" in case the checkbox is not checked. To do so, please repeat the step above to create a new event under the "Published Events" tab like as follows:

(Set installer property)
- Property: MY_PROP
- Argument: 0
- Condition: press the "..." button and insert the following condition: CHECKBOX_1_PROP = ""

This way, the property value will be set through the checkbox state.

Also, attached you can find a sample .AIP file which implements those said above, for your reference. I have also displayed a message box which shows the property value, so you can see that the property value is changing.
Bernd Sample.aip
(13.45KiB)Downloaded 401 times
Hope this helps.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Kratzer
Posts: 66
Joined: Wed Apr 10, 2013 5:36 pm

Re: Checkbox and setting property values

Wed Nov 14, 2018 3:28 pm

Hello Catalin,

thank you for the excellent support :-)

I've already made a sample, but I was a bit confused about the log messages in run mode:

"...deleting property, it's current value is..."

Now is it right that assigned property is usually set to "" when unchecking a Checkbox in Dialog?

Best regards
Bernd

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

Re: Checkbox and setting property values

Wed Nov 14, 2018 4:30 pm

You're always welcome, Bernd.

I am glad I could help.
Now is it right that assigned property is usually set to "" when unchecking a Checkbox in Dialog?
If by this you mean the property assigned to your checkbox, then yes, that is correct.

All the best,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

marcusl0104
Posts: 3
Joined: Wed May 25, 2022 6:27 am

Re: Checkbox and setting property values

Wed May 25, 2022 6:30 am

What if you want to set the checkbox property in command line as well? I tried msiexec.exe [filename] CHECKBOX_PROP="" but it doesn't do anything.

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

Re: Checkbox and setting property values

Wed May 25, 2022 12:13 pm

Hello Marcus and welcome to our forums,

You can change the state of a checkbox from the command line as well, through its assigned property.

For instance, in your case, if the checkbox is, by default, checked, the following command line should uncheck it:

Code: Select all

msiexec /i <path_to_msi> CHECKBOX_1_PROP=""
If the checkbox is already unchecked by default, then indeed nothing will happen.

Hope this helps!

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

marcusl0104
Posts: 3
Joined: Wed May 25, 2022 6:27 am

Re: Checkbox and setting property values

Thu May 26, 2022 7:03 am

Thanks, running it with cmd instead of powershell worked.

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

Re: Checkbox and setting property values

Mon May 30, 2022 4:20 pm

You are always welcome!

Glad to hear everything works as expected now.

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

Return to “Common Problems”