[wix-users] Storing/Retrieving/Changing Registry Key by Checkbox value

signal at dynax.at signal at dynax.at
Sun Oct 16 02:35:31 PDT 2022


Hi,

in our wixtoolset 3.11.2 based installer we need to set a registry key according to a Checkbox value. For install/uninstall this already works, by awkwardly setting the property to a distinct value with a SetProperty action in the Sequence=“execute” if the property has not been set by the checkbox.

The registry value is either 0 (not checked) or 1 (checked).

There are two issues with that approach:
1. In a “change” installation the Registry key does not get updated. It seems that either the RegistryValue and/or that the above value magic is not executed.

2. It would be nice for a “change” installation to retrieve the current Registry value and set the checkbox accordingly. However no matter what I don’t seem to be able to control the property correctly. An inverse value magic like the above is probably required, but I can’t figure out how this can be done, where it needs to be scheduled and how to make to not conflict with the other SetProperty, which both probably have to have the same Id.

For readability I removed all not directly related tags and attributes:
I added the RegistrySearch which is not working, because it has no SetProperty “magic".

<?xml?>
<Wix>
	<Product>
		<Package>
		<Media>

		<Property Id="MY_PROPERTY" Value="1" Secure="yes">
			<RegistrySearch Id="my_property" Root="HKLM" Key="SOFTWARE\$(var.my_property)" Name=“my_property" Type="raw"/>
		</Property>

		<Directory>
			<Component Id="my_property">
				<RegistryValue Root="HKLM" Key="SOFTWARE\$(var.my_property)" Type="integer" Name=“my_property" Value="[MY_PROPERTY]" KeyPath="yes"/>
			</Component>
		</Directory>
    
		<Feature>
			<ComponentRef Id="my_property"/>
		</Feature>

		<UI>
			<Dialog>
				<Control Id="checkbox" Type="CheckBox" X="45" Y="173" Width="300" Height="15" TabSkip="no" Default="yes" CheckBoxValue="1" Property="MY_PROPERTY"
					Text="Yes, I would like to set MY_PROPERTY."/>
			</Dialog>
		</UI>

		<SetProperty Id="MY_PROPERTY" Value="0" Before="InstallInitialize" Sequence="execute">NOT MY_PROPERTY</SetProperty>
	</Product>
</Wix>

Any hints or suggestions are highly appreciated, 
Thanks!

Viele Grüße/Cheers,
Hagen.



More information about the wix-users mailing list