0
votes

I'm trying to create an installer for a Windows Service, and I have no idea why it's failing.

Here's the fragment where I define the service-related pieces:

<ComponentGroup Id="ServiceComponents" Directory="InstallDirectory">
  <Component Id="ThingService" Guid="1F4D7F24-BC66-4E7A-AC33-A7E2133FC5B8" KeyPath="yes">
    <ServiceInstall Id="ThingServiceInstaller"
                    Type="ownProcess"
                    Name="ThingService"
                    DisplayName="Thing"
                    Description="Does Thing."
                    Start="auto"
                    ErrorControl="normal"
                    Vital="yes" />
    <ServiceControl Id="StartService"
                    Start="install"
                    Stop="both"
                    Remove="uninstall"
                    Name="ThingService"
                    Wait="yes" />
  </Component>
</ComponentGroup>

This is the last part that runs - the files are all deployed earlier, and I can see that they get where they're supposed to. When it gets to starting the service, I get the following error:

Service 'ThingService' (ThingService) failed to start. Verify that you have sufficient priveleges to start system services.

However, I don't see the service in the service list at all, so I don't know what it's even trying to start. I feel like I'm missing some sort of pointer to Thing.exe, but the examples I see around don't seem to have it either.

Here are the pieces from the verbose log that seem to be relevant:

1:

MSI (s) (50:F8) [16:14:38:880]: Component: ThingService; Installed: Absent; Request: Local; Action: Local

2:

MSI (s) (50:F8) [16:14:40:736]: Doing action: StopServices

MSI (s) (50:F8) [16:14:40:736]: Note: 1: 2205 2: 3: ActionText

Action 16:14:40: StopServices. Stopping services

Action start 16:14:40: StopServices.

StopServices: Service: Stopping services

Action ended 16:14:40: StopServices. Return value 1.

MSI (s) (50:F8) [16:14:40:740]: Doing action: DeleteServices

MSI (s) (50:F8) [16:14:40:740]: Note: 1: 2205 2: 3: ActionText

Action 16:14:40: DeleteServices. Deleting services

Action start 16:14:40: DeleteServices.

Action ended 16:14:40: DeleteServices. Return value 1.

MSI (s) (50:F8) [16:14:40:747]: Doing action: RemoveRegistryValues

MSI (s) (50:F8) [16:14:40:747]: Note: 1: 2205 2: 3: ActionText

Action 16:14:40: RemoveRegistryValues. Removing system registry values

Action start 16:14:40: RemoveRegistryValues.

Action ended 16:14:40: RemoveRegistryValues. Return value 1.

3:

MSI (s) (50:F8) [16:14:40:944]: Doing action: InstallServices

MSI (s) (50:F8) [16:14:40:944]: Note: 1: 2205 2: 3: ActionText

Action 16:14:40: InstallServices. Installing new services

Action start 16:14:40: InstallServices.

Action ended 16:14:40: InstallServices. Return value 1.

MSI (s) (50:F8) [16:14:40:945]: Doing action: StartServices

MSI (s) (50:F8) [16:14:40:945]: Note: 1: 2205 2: 3: ActionText

Action 16:14:40: StartServices. Starting services

Action start 16:14:40: StartServices.

StartServices: Service: Starting services

Action ended 16:14:40: StartServices. Return value 1.

4:

MSI (s) (50:F8) [16:14:40:994]: Executing op: ActionStart(Name=StopServices,Description=Stopping services,Template=Service: [1])

Action 16:14:40: StopServices. Stopping services

MSI (s) (50:F8) [16:14:40:996]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)

MSI (s) (50:F8) [16:14:40:996]: Executing op: ServiceControl(,Name=ThingService,Action=2,Wait=1,)

MSI (s) (50:F8) [16:14:40:996]: Executing op: ActionStart(Name=CreateFolders,Description=Creating folders,Template=Folder: [1])

5:

MSI (s) (50:F8) [16:14:41:817]: Executing op: ActionStart(Name=StartServices,Description=Starting services,Template=Service: [1])

Action 16:14:41: StartServices. Starting services

MSI (s) (50:F8) [16:14:41:817]: Executing op: ProgressTotal(Total=1,Type=1,ByteEquivalent=1300000)

MSI (s) (50:F8) [16:14:41:817]: Executing op: ServiceControl(,Name=ThingService,Action=1,Wait=1,)

StartServices: Service: ThingService

Error 1920. Service 'ThingService' (ThingService) failed to start. Verify that you have sufficient privileges to start system services.

EDIT1: It looks like the issue is with splitting the ServiceInstall/ServiceControl out into their own component, because it works if I put them into the same component as where the Files are defined.

1
I'd look at why you are returning 1 rather than 0 for your InstallServices action. You may also want to set Vital="yes" on ThingServiceInstaller so that the overall install fails if the service fails to install.ssnobody
@ssnobody: Vital="yes" is already on the ThingServiceInstaller - it's the last line. Any ideas as to what to look into?zimdanen
I would remove Starting of the service on install so just install the service then try starting the service manually to see where the problem is, maybe your application is not starting as Local System. Also check Event Viewer for app crashes.IlirB

1 Answers

0
votes

The ServiceInstall must be in the same Component as the service executable, because

Windows Installer defines the ServiceInstall table with a foreign key to the Component table and not a path to the executable (see http://msdn.microsoft.com/en-us/library/aa371637(VS.85).aspx).

Reference here.