I have created a custom dialog that allows the user to configure the account under which the service we are installing will run. I do this by attaching a property event to the Next button on my custom dialog that will set a [Account] property:
<Publish Property="Account" Value="[USERNAME]">USERACCOUNT = "1"</Publish>
<Publish Property="Account" Value="Local System"><![CDATA[USERACCOUNT <> "1"]]></Publish>
I then try to pick up the account property in the component that installs the service:
<Component Id="Service" Guid="*" >
<File Id="ServiceExe" KeyPath="yes" Source="$(var.ServiceFiles)\Service.exe" />
<ServiceInstall Vital="yes" ErrorControl="ignore" Type="ownProcess" Account="[Account]" Name="$(var.ServiceName)" Description="Service running as [Account]" Start="auto" />
<ServiceControl Id="ServiceControl" Remove="both" Name="$(var.ServiceName)" Start="install" Stop="both"/>
</Component>
My problem is that this component does not use the value published for [Account] even though I can see that the correct values are being published by the property event in the installer log. So my question is how can I ensure that the service installer component picks up the [Account] value published by my custom dialog ?
Use a public property, for example ACCOUNT. Private properties lose their modified values in InstallExecuteSequence.
Also, when installing a service for a specific account, make sure that the Log on as a service policy is set for that account. Otherwise the service will not start after installation.