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