views:

1278

answers:

7

Hey there,

I am trying to get my application an installer via WiX 3.0. The exact code is:

<File Id="ServiceComponentMain" Name="$(var.myProgramService.TargetFileName)" Source="$(var.myProgramService.TargetPath)" DiskId="1" Vital="yes"/>

<!-- service will need to be installed under Local Service -->
<ServiceInstall
      Id="MyProgramServiceInstaller"
      Type="ownProcess"
      Vital="yes"
      Name="MyProgramAddon"
      DisplayName="[removed]"
      Description="[removed]"
      Start="auto"
      Account="LocalService"
      ErrorControl="ignore"
      Interactive="no"/>
<ServiceControl Id="StartDDService" Name="MyProgramServiceInstaller" Start="install" Wait="no" />
<ServiceControl Id="StopDDService" Name="MyProgramServiceInstaller" Stop="both" Wait="yes" Remove="uninstall" />

Thing is, for some reason LocalService fails on the "Installing services" step, and if I change it to "LocalSystem" then the installer times out while trying to start the service.

The service starts fine manually and at system startup, and for all intents and purposes works great. I've heard there are issues getting services to work right under LocalService, but Google isnt really helping as everyone's responses have been "got it to work kthx".

Just looking to get this service set up and started during installation, that's all. Any help? Thanks!

+1  A: 

Have you tried ...

NT AUTHORITY\LocalService

Per this doc ...

... but the name of the account must be NT AUTHORITY\LocalService when you call CreateService, regardless of the locale, or unexpected results can occur.

JP Alioto
I think I tried that, but as "Local Service". Will try without.
Tom the Junglist
With Account="NT AUTHORITY\LocalService", I get the following:"Error 1923. Service 'My Program Long Name' (MyProgramAddon) could not be installed. Verify that you have sufficient privileges to install system services."Thing is, the installer is running as an administrator under Windows XP. I am confused :-(
Tom the Junglist
+2  A: 

reference: ServiceControl Table

The MSI documentation for ServiceControl Table states that the 'Name' is the string name of the service. In your code snipet, your ServiceControl 'Name' is set to the 'ID' for the ServiceInstall and not its 'Name'. So, your ServiceControl elements should read:

<ServiceControl Id="StartDDService" Name="MyProgramAddon" Start="install" Wait="no" />
<ServiceControl Id="StopDDService" Name="MyProgramAddon" Stop="both" Wait="yes" Remove="uninstall" />
Roger S
A: 

Had the same problem but with specified accounts, got bored of it and created a CA to start the service after the install was completed instead. Just don't bother trying to start it with MSI, just leave it to a CA, unless you get some quality info from somewhere.

BTW using LocalSystem and a manually started service works fine. Never got any other variations to work.

aristippus303
+1  A: 

Hi,

Please pay attention that in the documentation for ServiceInstall element it is written about the Account attribute that "The account under which to start the service. Valid only when ServiceType is ownProcess.". In your example you did not specify the ownProcess service type which may be the problem.

Ikaso
Hi,It does run under OwnProcess. I retyped the code by hand and I guess I forgot that directive. Thanks though!
Tom the Junglist
+1  A: 

I spent a while looking into this and discovered it was because I had the keypath attribute set on the the component not on the file. My wix file now looks like:

<Component Id="comp_WF_HOST_18" DiskId="1" KeyPath="no" Guid="3343967A-7DF8-4464-90CA-7126C555A254">
    <File Id="file_WF_HOST_18" Checksum="yes" Source="C:\Projects\GouldTechnology\Infrastructure\WorkflowHost\WorkflowHost\bin\Release\WorkflowHost.exe" KeyPath="yes"/>

      <ServiceInstall
                 Id="workflowHostInstaller"
                 Type="ownProcess"
                 Vital="yes"
                 Name="WorkflowHost"
                 DisplayName="Workflow Host"
                 Start="demand"
                 Account="[WORKFLOW_HOST_USER_ACCOUNT]"
                 Password="[WORKFLOW_HOST_USER_PASSWORD]"
                 ErrorControl="critical"
                 Interactive="no"/>
    <ServiceControl Id="StartWFService" Name="workflowHostInstaller" Start="install"  Stop="both" Remove="both" Wait="no" />

</Component>

Now I just need to work out how to give it the correct permissions...

gbanfill
A: 

I had the same problem. It turns out that I had a typo in the <ServiceControl Id="StartService" Name="MyServiceName" where my Name did not match the service name I specified in the service project when I created it.

This was also the problem with my service not uninstalling.

Nate Zaugg
A: 

We had the same problem occuring only on Windows XP machines were the service could not be installed. In the end we found that on XP the name setting from the WiX file is ignored and it instead used the service name set in the C# code. We happened to have a name in the code that contained white-space, i. e. "Blah Blah Service", when this was set to the same name as the WiX file used on Windows 7 it worked well.

Per Salmi