I have the following property:
<Property Id="UPDATEDB">1</Property>
A checkbox in the UI bound to that property:
<Control Id="updateDatabase" Type="CheckBox" CheckBoxValue="1" Height="15" Width="95" X="20" Y="74" Text="Update Database" Property="UPDATEDB" />
And a Custom Action which does something based on the value of this property
<CustomAction Id="RunDbMigration" Directory="INSTALLDIR" Return="check"
ExeCommand='[DBMIGRATIONDIR]\DbMigration.exe' />
<InstallExecuteSequence>
<Custom Action="RunDbMigration" After="InstallFinalize">UPDATEDB=1 AND NOT Installed</Custom>
</InstallExecuteSequence>
If I try to pass a value of 0 for UPDATEDB from the command line:
msiexec /i "Setup.msi" /l* UPDATEDB=0
or
msiexec /i "Setup.msi" /l* UPDATEDB="0"
the value of the checkbox is checked anyway. That said, the 0 passed in seems to be respected and the RunDbMigration action is not run...
What's going on here? Why is this such rocket science?
As others have mentioned, Checkboxes are not boolean in a 1/0 sense, they're boolean in a null/not-null sense.
To unset from the command line - you would want to use something like
msiexec /i "Setup.msi" /l* UPDATEDB=""
Chances are that your condition is looking specifically for the value of 1 before executing your custom action, which is why your CA isn't being run.
Installer properties are either set to a value or they are not set. Internally the value is just a string, so "0", "1", "true" and "false" are the same.
A checkbox control is checked when its property is set to a value (doesn't matter what) and unchecked when its property is empty.
This command line sets the property and checks the checkbox:
msiexec /i "Setup.msi" /l* UPDATEDB="0"
This command line doesn't set the property, so the checkbox is not checked:
msiexec /i "Setup.msi" /l*
The problem is the CheckBoxValue="1". You find the solution for your question here: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/How-to-conditionally-check-uncheck-a-checkbox-td5539262.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With