A.Pissicat
A.Pissicat

Reputation: 3295

Wix Installer unable to start service

I created a Wix setup to install a service. There is my product.wxs :

<?xml version="1.0" encoding="UTF-8"?>
<?define compagny = "MyCompagny"?>
<?define product = "My Service"?>
<?define service = "MyService"?>
<?define version = "!(bind.FileVersion.MyService.exe)"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="*" 
           Name="$(var.product)"
           Language="1033"
           Version="$(var.version)"
           Manufacturer="$(var.compagny)" 
           UpgradeCode="XXXXXXX">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>
        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <Media Id="1" Cabinet="MyService.cab" EmbedCab="yes" />

        <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
        <Directory Id="CPGNYFOLDER" Name="$(var.compagny)">
          <Directory Id="INSTALLFOLDER" Name="$(var.product)" >
            <Directory Id="Service_tessdata" Name="tessdata"/>
            <Directory Id="Service_x64" Name="x64"/>
            <Directory Id="Service_x86" Name="x86"/>            
          </Directory>
        </Directory>
            </Directory>
        </Directory>

    <ComponentGroup Id="InstallComponents">
      <Component Id="InstallService" Guid="XXXXXXX" Directory="INSTALLFOLDER">
        <File Id="MyService.exe.config"
              Name="$(var.service).exe.config"
              Source="$(var.MyService.TargetDir)\$(var.service).exe.config"
              Vital="yes"/>
        <File Id="MyService.exe"
              Name="$(var.service).exe"
              Source="$(var.MyService.TargetDir)\$(var.service).exe"
              Vital="yes"/>
        <!-- Install all dll -->

        <RemoveFile Id="ALLFILES" Name="*.*" On="both" />
        <ServiceInstall Id="ServiceInstaller"
                        Type="ownProcess"
                        Vital="yes"
                        Name="$(var.service)"
                        DisplayName="$(var.product)"
                        Description=""
                        Start="auto"
                        Account="LocalSystem"
                        ErrorControl="normal" />
        <ServiceControl Id="Service_Start" Name="MyService" Start="install" Wait="no" />
        <ServiceControl Id="Service_Stop" Name="MyService"  Stop="both" Remove="uninstall" Wait="yes" />
      </Component>

        <!-- Install all directories -->
    </ComponentGroup>

    <!-- Tell WiX to install the files -->
    <Feature Id="ProductFeature" Title="$(var.product)" Level="1">
      <ComponentGroupRef Id="InstallComponents" />
    </Feature>
    </Product>
</Wix>

When I try to install my service, I have error :

Service 'My Service' (MyService) failed to start. Verify that you have sufficient privileges to start system services

I saw that this error is a generic error. So I ignored it. In my INSTALLFOLDER I have all files. Then I started services.msc and try to start my service. The error is :

Cannot start the service on local computer. Error 193:0xc1

I try to have more details, but I can't find what is the problem. How can I fix this ?

Upvotes: 1

Views: 930

Answers (1)

A.Pissicat
A.Pissicat

Reputation: 3295

I finally found what was wrong.

In me service properties, I saw that the service path was pointing on MyService.exe.config.

I fixed the problem by adding KeyPath on .exe :

<File Id="MyService.exe"
      Name="$(var.service).exe"
      Source="$(var.MyService.TargetDir)\$(var.service).exe"
      Vital="yes"
      KeyPath="yes"/>

Upvotes: 1

Related Questions