WiX v3.7 - Installer Stuck on "Starting Services"

1.3k Views Asked by At

I'm creating an installer using wix and it's getting hung up on the StartServices action. Here is the only service I'm installing:

<Component Id="CMP_RemindexNP.exe" Guid="{3FB99890-752D-4652-9412-72230695A520}">
    <File Id="FILE_INSTALLFOLDER_RemindexNPEXE" Source="RemindexNP.exe" KeyPath="yes"/>
    <RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\RemindexNP\Parameters">
      <RegistryValue Id="rg_remNP1" Action="write" Name="AppDirectory" Value="[INSTALLFOLDER]" Type="string"/>
      <RegistryValue Id="rg_remNP2" Action="write" Name="Application" Value="[INSTALLFOLDER]RemindexNP.exe" Type="string"/>
    </RegistryKey>
    <ServiceInstall DisplayName="RemindexNP" Id="srv_remNP" Name="RemindexNP" Start="auto" Type="shareProcess" ErrorControl="ignore"/>
    <ServiceControl Id="srvc_remNP" Name="RemindexNP" Remove="both" Start="install" Stop="uninstall" Wait="no"/>
</Component>

Here's the StartService action in the log file:

Action 17:15:08: StartServices. Starting services
Action start 17:15:08: StartServices.
StartServices: Service: Starting services
Action ended 17:15:08: StartServices. Return value 1.

If I wait for 5 - 10 minutes, the installer something about "ending prematurely". Or I can stop the task in task manager and after a few minutes, I get the same dialog.

I've tried setting the Type attribute in ServiceInstall to shareProcess and ownProcess, neither of which work. I've also tried setting Wait to no and yes.

Is there something wrong with my ServiceInstall element?

1

There are 1 best solutions below

0
On

I have the following Service Component in my installer and it works. When I came across a problem during the installation in which the service was not started correctly it was very helpful to have the some kind of logging mechanism in the service. The installation could not be completed because the service failed to start due to some misconfiguration. I could not have analyzed and resolved the problem was I not able to have a look at the eventlog which was created by my installer and used by that service. I advise you to go the same route, because syntactically your ServiceInstall and ServiceControl elements look correct.

<Component Id="CMP_SERVICE" Guid="YOURGUIDHERE">
<File Source="Files/Service.exe" Id="Service.exe" KeyPath="yes" Compressed="no" />
<ServiceInstall
  Id="SvcInstallService"
  Name="Service"
  DisplayName="Service"
  Type="ownProcess"
  Description="Service Desc"
  Start="auto"
  ErrorControl="normal">
  <util:ServiceConfig
    ServiceName="Service"
    FirstFailureActionType="restart"
    SecondFailureActionType="restart"
    ResetPeriodInDays="1"
    RestartServiceDelayInSeconds="5"
    ThirdFailureActionType="restart"/>
</ServiceInstall>
<ServiceControl
  Id="sc_Service"
  Name="Service"
  Start="install"
  Stop="both"
  Remove="uninstall"
  Wait="no" />
</Component>

To create an Eventlogsource use something like the following code:

<PropertyRef Id="NETFRAMEWORK20"/>
<PropertyRef Id="NETFRAMEWORK40FULL"/>
<Component Id="CMP_ServiceEventLogNetfx2" Guid="YOURGUIDHERE">
    <util:EventSource Name="Service" EventMessageFile="{[NETFRAMEWORK20INSTALLROOTDIR]}EventLogMessages.dll" Log="YourLog" KeyPath="yes"/>
    <Condition>
        <![CDATA[(Installed OR NETFRAMEWORK20) AND VersionNT < 600]]>
    </Condition>
</Component>
<Component Id="CMP_ServiceEventLogNetfx4" Guid="YOURGUIDHERE">
    <util:EventSource Name="Service" EventMessageFile="{[NETFRAMEWORK20INSTALLROOTDIR]}EventLogMessages.dll" Log="YourLog" KeyPath="yes"/>
    <Condition>
        <![CDATA[(Installed OR NETFRAMEWORK40FULL) AND VersionNT >= 600]]>
    </Condition>
</Component>

And of course you have to use that eventlog in your service. Use the System.Diagnostics.EventLog class with its WriteEntry method for that purpose.

The last step is to open up the eventviewer (eventvwr.msc) during the installation and to have a look at your service's log.