Reputation: 341
I have a Service to install by my installer. On UI user can choose to install this service as LocalSystem or with specified user credentials. My Wix code looks like this:
<Component Id="C.MyService.exe" Guid="{Guid}">
<File Id="MyService.exe" Name="MyService.exe" KeyPath="yes" Vital="yes"
Source="MyServicePath" />
<ServiceInstall Id="MyServiceInstall" DisplayName="[SERVICE_NAME]" Account="[SERVICE_ACCOUNT]" Password="[SERVICE_PASSWORD]" Name="[SERVICE_NAME]" ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes" Interactive="no">
</ServiceInstall>
<ServiceControl Id="MyServiceStart" Name="[SERVICE_NAME]" Start="install" Wait="no" />
<ServiceControl Id="MyServiceStop" Name="[SERVICE_NAME]" Stop="both" Wait="yes" />
<ServiceControl Id="MyServiceRemove" Name="[SERVICE_NAME]" Remove="uninstall" Wait="yes" />
</Component>
<Component Id="SetStartServicePermission" Guid="{Guid}">
<CreateFolder/>
<Condition>NOT USE_LOCALSYSTEM_ACCOUNT</Condition>
<util:User Id="ServiceUser" Name="[SERVICE_ACCOUNT]" Password="[SERVICE_PASSWORD]" CreateUser="no" LogonAsService="yes" UpdateIfExists="yes" />
</Component>
When I choose LocalSystem, service installs and works fine. But with custom user credentials service installs, but fails to start with an error "Service ServiceName failed to start. Verify that you have sufficient privileges to start system services". The custom user already exists and belong to Administrators group. When I install with LocalSystem and change Log On credentials for service manually, it starts successlully.
Upvotes: 0
Views: 2211
Reputation: 341
Fixed. I have misprinted in ServicePassword property name and installer set empty password for service user.
Upvotes: 0
Reputation: 8850
Just for completeness - I successfully used the following code to give LogonAsService permission:
<util:User Id="ProcessingServiceUser" Domain="[APP_USER_DOMAIN]" Name="[APP_USER_NAME]" Password="[APP_USER_PASSWORD]" CreateUser="no" LogonAsService='yes' UpdateIfExists='yes' />
So CreateUser should be 'no', but UpdateIfExists='yes'.
Though I think this is not your problem as you said that user already have this permission.
Is your installer launches with elevated permissions? What OS version do you install to? I suppose you created per-user installation so that it doesn't ask for elevated permissions but after that you are trying to start service. Try launching your MSI from administrative command-line (msiexec /i YourInstaller.msi) instead of double-clicking it.
Upvotes: 1
Reputation: 55581
You have the createuser attribute as false. Therefore WiX isn't creating/updating the user to give the SeLogonAsService right. When you go into Services.msc and enter the creds it implicitly does this for you and starts working.
Upvotes: 0