I'm using Wix to install a windows service, but need the option for it to use the LocalSystem account or use an account provided by the user. How should I toggle between a hard coded value and the user value? For the service I have:
<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes" Start="auto"
Account="[SERVICELOGONUSER]" Password="[SERVICELOGONPASSWORD]" ErrorControl="normal"
Interactive="no"/>
In the UI I have the property:
<Property Id="SERVICELOGONUSER" Value="LocalSystem"/>
In a dialog I have:
<Control Type="CheckBox" Width="200" Height="25" X="25" Y="75" Id="LocalCheckBox"
Property="UseLocalSystem" CheckBoxValue="1" Text="Use LocalSystem Account"/>
<Control Type="Edit" Width="200" Height="15" X="25" Y="115" Id="AccountTextbox"
Property="SERVICELOGONUSER">
<Condition Action="disable">UseLocalSystem = 1</Condition>
<Condition Action="enable"><![CDATA[UseLocalSystem <>1]]></Condition
</Control>
But this will just display the hard coded value, which the user can edit.
I would advise making two components with mutually exclusive conditions using your
UseLocalSystem
property, like this:WiX has a limitation where if you need the same file in two places, you need to have a
File
element for it in each place, which is why I have twoFile
elements with differentId
's. No worries though, thanks to smart cabbing, WiX toolset will only compress the duplicated content across the Components once.This way, it won't matter if the user starts to change the
SERVICELOGONUSER
andSERVICELOGONPASSWORD
and decide to useLocalSystem
instead.Hope this helps!