I've a Wix 3.10 installer with 3 Windows Service, when i run the MSI in my local PC (Windows 8) the Services are installed correctly. I can Stop, Start and too Unistall the Services with the MSI.
The problem is when I install the MSI on Windows Server 2016, I can't Stop and Unistall the service. The Xml of the Wix Installer is the Next.
<ServiceInstall
Id="WindowsService"
Name="Service"
DisplayName="My windows Service"
Description="Process text Files and moves them into Database"
Type="ownProcess"
Vital="yes"
Start="auto"
Account="[WIX_ACCOUNT_LOCALSERVICE]"
ErrorControl="critical"
Interactive="no"/>
<ServiceControl
Id="ServiceControl"
Name="Service"
Start="install"
Stop ="both"
Remove="uninstall"
Wait="yes"/>
</Component>
Related
I am getting the following error when running my installer a secondary PC, but it works when i run it on my development machine.
MSI (s) (90:2C) [16:22:35:704]: Executing op: ServiceInstall(Name=PCR2,DisplayName=Amusoft PC Remote 2,ImagePath="C:\Program Files\Amusoft\PC Remote 2\web\Amusoft.PCR.Server.exe",ServiceType=16,StartType=2,ErrorControl=32771,,Dependencies=[~],,StartName=LocalSystem,Password=**********,Description=Backend service required for PC Remote to interact with this computer,,)
InstallServices: Service:
Error 1923. Service 'Amusoft PC Remote 2' (PCR2) could not be installed. Verify that you have sufficient privileges to install system services.
This is my fragment for installing and starting the service
<Fragment>
<Component Id="RegistrySetValues" Guid="CCA1011E-0C44-4111-9089-A4F5D49D3D51" Win64="yes" Directory="WEBFOLDER">
<RegistryKey Root="HKLM" Key="SOFTWARE\Amusoft\PC Remote 2" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
<RegistryValue
Type="string"
Name="InstallLocation"
Value="[PRODUCTNAMEFOLDER]"/>
<RegistryValue
Type="string"
Name="Version"
Value="$(var.ProductVersion)"/>
</RegistryKey>
</Component>
<Component Id='BackendServerExe' Guid='7B39D2A5-140F-452D-BAEC-0B965A15CCC9' Directory='WEBFOLDER'>
<File Id='BackendServer' Name='Amusoft.PCR.Server.exe' Vital='yes' Source='$(var.SolutionDir)..\artifacts\msi\web\Amusoft.PCR.Server.exe' KeyPath='yes'/>
<fire:FirewallException
Name='Amusoft PC Remote 2 Server'
Id='BackendServerFirewall'
Port='[CUSTOM_PORT]'
Protocol='tcp'
Profile='all'
Scope='localSubnet'
IgnoreFailure='no'
Description='Amusoft PC Remote 2 Server'/>
<ServiceInstall Name='$(var.ServiceName)'
Type='ownProcess'
Start='auto'
Account="LocalSystem"
DisplayName="Amusoft PC Remote 2"
Id="PCR2.Install"
Description="Backend service required for PC Remote to interact with this computer"
Vital="yes" ErrorControl="critical">
<!-- Vital="yes" ErrorControl="critical"> -->
<util:ServiceConfig
FirstFailureActionType="restart"
SecondFailureActionType="restart"
ThirdFailureActionType="none"
ResetPeriodInDays="1"
ServiceName="$(var.ServiceName)"
RebootMessage="PC Remote 2 requires a reboot"
RestartServiceDelayInSeconds="180"
/>
</ServiceInstall>
<!-- <ServiceControl Id="PCR2.Control.Start" -->
<!-- Name="$(var.ServiceName)" -->
<!-- Start="install" -->
<!-- Wait="no" /> -->
<ServiceControl Id="PCR2.Control.Stop"
Name="$(var.ServiceName)"
Stop="uninstall"
Remove="uninstall"
Wait="yes" />
<!-- <ServiceControl Id="PCR2.Control" -->
<!-- Name="$(var.ServiceName)" -->
<!-- Remove="both" -->
<!-- Start="install" -->
<!-- Stop="both"/> -->
</Component>
</Fragment>
I looked at these questions, but that did not fix my issue
How to install and start a Windows Service using WiX
Wix installer: Verify that you have sufficient privileges to start system services
Is this related to strong name signing? I don't understand why it works on my dev machine, but fails on a secondary machine
Solution: The .NET 5 hosting runtime was missing.
Lacking Runtime: Typically you lack a runtime if the service starts on your dev-computer and not on the test box. Common lacking
runtimes: .Net, .Net Core, Java, VC++ Runtime, MS-XML (legacy), etc... Virtual machines often lack most runtimes in their base state, and this is a very common problem when testing setups.
Debug Binaries: Another variation of the above is to install debugging binaries that depend on completely different runtime files than the release version files. These debugging binaries are the binaries built when you use the "Debug" configuration in your Visual Studio project. They depend on dlls with "d" added to their file names (C++).
Other Ideas: There are many other potential causes. Here are some check lists for application and service launch failures:
Crash on Launch
Application Launch Problems
Bitness: One should mention bitness as another "first issue" to check (x86 vs x64 binaries - incompatibilities and confusion).
Other Links:
Tools for dependency scanning your binaries
Windows Services Frequently Asked Questions (FAQ)
General debugging links of various types
I'm using WiX 3.1.1 to install an exe and a service. Sometimes, the MSI install fails with a fairly generic error:
Error 1923. Service 'MyService' (MyService) could not be installed.
Verify that you have sufficient privileges to install system services.
Experimentally, this appears to be because the service already exists, and my xml uses Vital="yes"
I would like to have the MSI ensure the service is installed, but accept (or repair) it if it's already present. It sounds like I should set Vital="no", will this cause it to ignore other errors? Is there a way to limit what kind of errors are ignored? Is there a best practice I'm missing?
For reference, a redacted snippet of my xml:
<Component Id="REDACTED" Guid="{REDACTED}" Win64="yes">
<File
Id="filB754EE270009E240193A8279D1529A43"
Name="myservice.exe"
KeyPath="yes"
DiskId="1"
Source="SourceDir\File\filB754EE270009E240193A8279D1529A43" />
<ServiceControl
Id="MyService"
Name="MyService"
Start="install"
Stop="both"
Remove="uninstall"
Wait="no" />
<ServiceInstall
Id="MyService"
Name="MyService"
Type="ownProcess"
Start="auto"
ErrorControl="normal"
Vital="yes"
Account="[SERVICEACCOUNT]"
Arguments="svc -config "C:\Program Files\MyService\conf\service.flags""
Description="My Service">
<ServiceConfig
ServiceName="MyService"
FirstFailureActionType="restart"
SecondFailureActionType="restart"
ThirdFailureActionType="restart"
ResetPeriodInDays="1"
RestartServiceDelayInSeconds="5"
xmlns="http://schemas.microsoft.com/wix/UtilExtension" />
</ServiceInstall>
</Component>
I am trying to install a windows service using wix but I can't seem to point the file for the service to the user selected install directory.
<Component Id="MyServiceInstaller_ServiceControl" Guid="B72CAA3F-F2DB-48D2-90DD-061209AB2CE5" Directory="INSTALLDIR">
<CreateFolder />
<File Id='MyServiceEXE' Name='MyService.exe' DiskId='1' Source='[INSTALLDIR]MyService.exe' KeyPath='yes'/>
<ServiceInstall Id="MyServiceInstaller_ServiceInstall"
Type="ownProcess"
Vital="yes"
Name="My Service"
DisplayName="My Service"
Description="This will make windows services great again!"
Start="auto"
Account="NT AUTHORITY\LocalService"
ErrorControl="ignore"
Interactive="no" />
<ServiceControl Id="MyServiceInstaller_ServiceInstall"
Name="My Service"
Stop="both"
Remove="uninstall"
Wait="yes" />
</Component>
The issue seems to be when I use any [PROPERTY] directory I get the following error.
error LGHT0103 : The system cannot find the file
'[INSTALLDIR]MyService.exe'.
How do I tell Wix to use the installation folder the user selected as the path for the service?
File/#Source points to the file in your build environment. Component/#Directory tells Windows Installer where the file should be installed. That controls the file used to install and control the service.
I'm using Wix to create my application installer and using it to install an assembly in the GAC and it works fine.
My issue is when I'm setting the assembly property 'copy local=false' and I'm executing the installation, then my services is not being installed cause it can't find this dll in the local folder and it's not being installed to GAC yet.
If I'll install another component from the EXE installation and will verify that the DLL is in the GAC I will be able then to install the service.
I'm using Paraffin.exe to go all over my application directory and generate a wix file and also using Mold file to add component not from this directory.
<DirectoryRef Id="Manager">
<Component Id="NlogGACRegisterComponent" Guid="1B224CD1-6EE8-46D3-9335-A84B7D8FB87B">
<File Id="NlogDLL" Name="Nlog.DLL" Source="..\Logging\Nlog.DLL" KeyPath="yes" Vital="yes" Assembly=".net"/>
</Component>
<Component Id="ManagerServiceComponent" Guid="EA31E161-4331-4A82-8F2B-7E26F62C96D6">
<File Id="StateManagerServiceEXE" Name="ManagerHostService.exe" DiskId="1" Source="..\ManagerHostService.exe" KeyPath="yes" Vital="yes" />
<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Name="ManagerHostService" DisplayName="Manager Service" Description="Manager Service" Start="auto" Account="[SERVICEACCOUNT]" Password="[SERVICEPASSWORD]" ErrorControl="normal">
<util:PermissionEx User="Everyone" GenericAll="yes" ServiceChangeConfig="yes" ServiceEnumerateDependents="yes" ChangePermission="yes" ServiceInterrogate="yes" ServicePauseContinue="yes" ServiceQueryConfig="yes" ServiceQueryStatus="yes" ServiceStart="yes" ServiceStop="yes" />
</ServiceInstall>
<ServiceControl Id="StartService" Start="install" Name="ManagerHostService" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
</DirectoryRef>
This in the Mold file which responsible to install the DLL to GAC and then the service.
How can I make sure it first install the DLL's and then the service?
All files and Dlls ARE installed by the time that services are started. Look in your MSI file with Orca at the InstallExecuteSequence (or look in a verbose log) and you'll see that InstallServices and StartServices are after InstallFiles.
The issue is that assemblies aren't installed and available in the GAC until InstallFinalize, this is described here:
https://msdn.microsoft.com/en-us/library/aa370063(v=vs.85).aspx
where it says "This means you cannot use the ServiceControl Table to start the service, instead you must use a custom action that is sequenced after InstallFinalize." which is what you'll need to do.
How can i stop my service at uninstall in Win7 or Vista with UAC on from WIX?
When i uninstall my service from Control Panel in Win7 or Vista with UAC on I always get "File is in use message". How can i stop it so that message won't appear?
I have this code in Wix:
<ServiceInstall Id='MyServiceInstall' DisplayName='OnPremises Gateway' Name='OPGatewayService'
ErrorControl='normal' Start='auto' Type='ownProcess' Vital='yes' Account='NT AUTHORITY\NetworkService' />
<ServiceControl Id="StartOPGatewayServiceControl" Name="OPGatewayService" Wait="no" Start="install" />
<ServiceControl Id="StopOPGatewayServiceControl" Name="OPGatewayService" Stop="both" Wait="yes" Remove="uninstall"/>
Thank you,
Adriana
Unfortunately, the "File in use" detection is early. Check out the MSI SDK documentation about their interaction: http://msdn.microsoft.com/en-us/library/aa372466(VS.85).aspx
After investigating more about this, the solution is to use a program at uninstall (like Uninstall.exe) which requires admin rights from user before any actions that imply system changes (like stop service). And from that program run MsiExec.exe /X[MsiProductId]