0

after a few days of not finding a solution i decided to asking you. Hope someone can help me.

I created a WIX Project that should install a Windows Service and run this service afterwards by a special User. (keep in mind in the past we used the old installer project of VS2010 in which we did exactly the same. So the user on the target machine exists and can do that.) Sadly i got every time the log entry "Error 1920. Service 'TransformService' failed to start. Verify that you have sufficient privileges to start system services.".

First of all here my Code that we are using:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*" Name="Installation" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="901a337d-3a75-49b5-b345-134684d73442">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <!-- move install directory selected in wizzard to installation -->
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLLOCATION" />
    <!-- check if drive E: exist and set as default -->
    <Property Id="NEWINSTALLDIR" Value="E:\">
      <DirectorySearch Id="SearchNewDefaultInstallRoot" Path="E:\" Depth="1" />
    </Property>
    <CustomAction Id="DirectorySet" Property="TARGETDIR" Value="[NEWINSTALLDIR]" />
    <CustomAction Id="InstallDirectorySet" Directory="INSTALLLOCATION" Value="com\serviceFolder" />
    <InstallExecuteSequence>
      <Custom Action="DirectorySet" Before="LaunchConditions">TARGETDIR="E:\"</Custom>
      <Custom Action="InstallDirectorySet" After="CostFinalize">INSTALLLOCATION="com\serviceFolder"</Custom>
    </InstallExecuteSequence>
    <Property Id="DOMAIN" Value="com" Secure="yes" />
    <Property Id="SERVICE_USER" Value="user1" Secure="yes" />
    <Property Id="SERVICE_USER_PASSWORT" Value="pw1" Secure="yes" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <!--embed CAB-Package in msi file-->
    <MediaTemplate CompressionLevel="high" EmbedCab="yes" />
    <!-- define which components will be part of installation -->
    <Feature Id="ProductFeature" Title="Installation Target" Level="1">
      <ComponentRef Id="ProductStartComponent" />
      <ComponentGroupRef Id="GeneratedFiles" />
    </Feature>
    <!-- define type of installation wizzard -->
    <UIRef Id="WixUI_InstallDir" />
  </Product>
  <!-- define installation location -->
  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLLOCATION" Name="serviceFolder">
          <Component Id="ProductStartComponent" Guid="" KeyPath="yes">
            <util:User Id="UpdateUserLogonAsService"
                       UpdateIfExists="yes"
                       FailIfExists="no"
                       CreateUser="no"
                       Name="[DOMAIN]\[SERVICE_USER]"
                       LogonAsService="yes"/>
            <ServiceInstall Id="ServiceInstaller"
                            Type="ownProcess"
                            Vital="yes"
                            Name="TransformService"
                            DisplayName="My TransformService"
                            Description="My TransformService description"
                            Start="auto"
                            Account="[DOMAIN]\[SERVICE_USER]"
                            Password="[SERVICE_USER_PASSWORT]"
                            ErrorControl="normal"
                            Interactive="no">
            </ServiceInstall>
            <ServiceControl Id="ServiceControl_Start" Name="TransformService" Start="install" Wait="no" />
            <ServiceControl Id="ServiceControl_Stop" Name="TransformService" Stop="both" Remove="uninstall" Wait="yes" />
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>
</Wix>

Here is the generated file (*.wxs):

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="INSTALLLOCATION">
            <Component Id="cmpA36C3656F2234BFB24DBB332EC935E09" Guid="*">
                <File Id="filABEE616FA22E22792C8C1D1DC9BCEC47" KeyPath="yes" Source="$(var.ServiceFilesDir)\MyLib.dll" />
            </Component>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="GeneratedFiles">
            <ComponentRef Id="cmpA36C3656F2234BFB24DBB332EC935E09" />
        </ComponentGroup>
    </Fragment>
</Wix>

The generated File will be created by my Wix-Project using this

<Target Name="BeforeBuild"> <HeatDirectory ... /> </Target>

Well if this is not enough information please say a word an i will describe it in more details. Maybe someone found already the problem.

EDIT: I have seen many examples in which all set the exe-file in the component element in which is also the ServiceInstall element. So i did the same after using some XSLT transformation. Now i see a strange behavior of my service. Apparently it tries to start the service and it generates some log-files. The strange thing is, it generates multiple of it and normally it should only be one! The installer dialog keeps hanging at the same position as bevor. "Starting Service". Does someone has an idea?

Here is the Code again:

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLLOCATION" Name="serviceFolder">
                <File Id="fil1B3AEFCBBA787AF73A7D8BE34AC0F615" KeyPath="yes" Source="$(var.FilesDir)\Service.Host.exe" />
                <File Id="filDA3F2F6204CEA1AF93216D42BF163D93" Source="$(var.FilesDir)\Service.Host.exe.config" />
                <Component Id="ProductStartComponent" Guid="50451FB8-1473-4BDD-FE1F-AAB2B7B3A4CD">
                    <util:User Id="UpdateUserLogonAsService"
                           UpdateIfExists="yes"
                           FailIfExists="no"
                           CreateUser="no"
                           Name="[DOMAIN]\[SERVICE_USER]"
                           LogonAsService="yes"/>
                    <ServiceInstall Id="ServiceInstaller"
                                Type="ownProcess"
                                Vital="yes"
                                Name="TransformService"
                                DisplayName="My TransformService"
                                Description="My TransformService description"
                                Start="auto"
                                Account="[DOMAIN]\[SERVICE_USER]"
                                Password="[SERVICE_USER_PASSWORD]"
                                ErrorControl="normal"
                                Interactive="no">
                    </ServiceInstall>
                    <ServiceControl Id="Service.Host.exe" 
                            Name="Service.Host.exe" 
                            Start="install"
                            Stop="both"
                            Remove="uninstall"
                            Wait="no" />
                </Component>
            </Directory>
        </Directory>
    </Directory>
</Fragment>

Thanks & Greets Alex

Alex1111
  • 1
  • 2
  • Shouldn't you add PermissionEx element to your ServiceInstall element? Error says you don't have premissions~ @Edit found [something like this](http://stackoverflow.com/questions/20193681/wix-heatdirectory-serviceinstall) – Buzka91 Oct 15 '14 at 12:33
  • In this case I'd suspect that the account is invalid in some way. If the install completes ok can you start the service successfully? If yes then there may be a missing dependency. If it doesn't start then check the credentials. I am very suspicious that you have ...PASSWORT there when I'd expect ...PASSWORD unless you're German. – PhilDW Oct 15 '14 at 17:24
  • @Buzka91: I tried to use PersmissionEx but still the same result. – Alex1111 Oct 16 '14 at 06:52
  • @PhilDW: Ok it should be PASSWORD but i use the same wording at both positions so this can not be the problem. And to answer your Question. No the installation does not complete and run the service. If i delete the ServiceInstall element the files will be successful copied and i can run it manually! – Alex1111 Oct 16 '14 at 06:55

1 Answers1

0

Well i found the problem. In my project i used the ServiceBase-class for checking if i have to start my service as console application or windows service. And there lies the problem. It tried to start it as console application. :( After fixing that it was running nicely.

Sorry to disturb you!

Well may i ask you about some other problem. I would like to set the starting path in install dialog to another drive and path like: E:\servicefolder\myservice. Sadly all my changes will be ignored and it uses the standard path C:\Program Files... Can someone help me?

Thx Alex

Alex1111
  • 1
  • 2
  • Sure, it's [explained here](http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Setting-different-TARGETDIR-td7583402.html). TARGETDIR is looking for most free disk, usually its C: @Edit or [here](http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/How-to-change-TARGETDIR-to-e-drive-td703452.html) – Buzka91 Oct 16 '14 at 08:50