Wix MSI Package: For Windows Service

Error: Creating a new installer using the WiX toolkit for the Windows service. Failed to install the service. Getting error
Error screenshot

Environment

  • Microsoft visual studio 2017
  • Windows 7
  • WiX v3 Toolkit: Setup for MSI

Problem / Purpose

I want to create an MSI that installs a Windows service.

On Installation:

Windows service is installed and displayed in services.msc

In UnInstall:

Stop and delete the service.

My service window has many dependencies that will be used when the service starts.

I added all the files as a component and added a ServiceDependency for each of the component identifiers, but still could not resolve the error. The error in the event viewer also matches the screenshot above.

Any pointers are welcome.

My code

  <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> <MediaTemplate EmbedCab="yes" /> <Feature Id="ProductFeature" Title="LayoutSwitcher" Level="1"> <ComponentGroupRef Id="ProductComponents" /> </Feature> </Product> <Fragment> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLFOLDER" Name="LayoutSwitcher" /> </Directory> </Directory> </Fragment> <Fragment> <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"> <Component Id="PlcmLayoutSwitcherWinSvc.exe" Guid="PUT_GUID_HERE" KeyPath="yes"> <File Id="LayoutSwitcherWinSvc.exe" Name="LayoutSwitcherWinSvc.exe" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe" /> <CreateFolder /> <ServiceInstall Id="LayoutSwitcher" Type="ownProcess" Vital="yes" Name="LayoutSwitcher" DisplayName="LayoutSwitcher" Description="LayoutSwitcher" Start="auto" Account="NT AUTHORITY\LocalSystem" ErrorControl="ignore" Interactive="no"> <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="LayoutSwitcher" Wait="yes" /> </Component> <Component Id="logoicon.ico" Guid="PUT_GUID_HERE"> <File Id="logoicon.ico" Name="logoicon.ico" Source="$(var.LayoutSwitcherWinSvc_ProjectDir)logoicon.ico" /> </Component> <Component Id="LayoutSwitcherWinSvc.exe.config" Guid="PUT_GUID_HERE"> <File Id="LayoutSwitcherWinSvc.exe.config" Name="LayoutSwitcherWinSvc.exe.config" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe.config" /> </Component> <Component Id="Transactions.dll" Guid="PUT_GUID_HERE"> <File Id="Transactions.dll" Name="Transactions.dll" Source="$(var.LayoutSwitcherWinSvc_TargetDir)Transactions.dll" /> </Component> <Component Id="Transactions.Cfg.dll" Guid="PUT_GUID_HERE"> <File Id=" Transactions.Cfg.dll" Name="Transactions.Cfg.dll" Source="$(var.LayoutSwitcherWinSvc_TargetDir) Transactions.Cfg.dll" /> </Component> 

EDIT: 1

Updated source code after removing service dependencies, but still getting the same error.

EDIT: 2

Gaps removed, but still getting the same errors.

EDIT: 3

Detailed logs added. Please download it from the following link. http://www.yourfilelink.com/get.php?fid=1432133

+5
source share
4 answers

Can you try this piece of wix code? I cleaned it up a bit to remove some defaults.

If you do not want to host a file with a different file name, you do not need the Name attribute.

If you want your service to start as a local system, you need to set up an empty account. If you want it to run as a specific user, then you can set the properties on your command line SVCACCOUNT = someuser SVCPASSWORD = "password", otherwise just skip them.

If the name and identifier match, you can skip the identifier.

I prefer to use variables for things that I use in several places to avoid typos, such as ServiceName, which is used in ServiceInstall and ServiceControl, which I use:

<WixVariable Id="ServiceName" Value="LayoutSwitcher" />

 <Component Id="PlcmLayoutSwitcherWinSvc.exe" Guid="PUT_GUID_HERE"> <File Id="LayoutSwitcherWinSvc.exe" Source="$(var.LayoutSwitcherWinSvc_TargetDir)LayoutSwitcherWinSvc.exe" KeyPath="yes" /> <ServiceInstall Name="!(wix.ServiceName)" DisplayName="LayoutSwitcher" Description="LayoutSwitcher" ErrorControl="ignore" Type="ownProcess" Vital="yes" Start="auto" Account="[SVCACCOUNT]" Password="[SVCPASSWORD]" Interactive="no" /> <ServiceControl Id="ServiceControl_!(wix.ServiceName)" Name="!(wix.ServiceName)" Start="install" Stop="both" Remove="uninstall" Wait="yes" /> </Component> 

The log you recorded is incomplete, run the installer to the end and attach the log only after you close the installer. IMO debug log is not required.

+3
source

Try to make both Name attributes the same in the setting and control. They must match exactly, but they do not. You are trying to start a non-existent service.

+4
source

Your message:

"Failed to save ACL failure information with error 0x80070424; Error 0x80070424: Failed to get security information for the object; CustomAction ExecSecureObjects returned a valid error code 1603"

has nothing to do with services. Ideally, you should close this question because the maintenance problem has been resolved, and now you have a separate problem described by this error message.

Somehow, you managed to invoke a custom WiX action called ExecSecureObjects, which has nothing to do with your services. Somewhere in your WiX you are trying to protect some objects with PermissionEx from the WiX util extension. This is the problem you are seeing right now.

+4
source

ServiceDepenency elements display a list of DLLs and other files that your executable depends on. This is not the intent of the ServiceDependency element. It should list the other services that should be started before this service. The error you received is most likely due to the fact that LayoutSwitcherWinSvc.exe.config and all * .dll files that you list with others are not the names of the services installed on the target machine.

A fix is ​​likely to remove these ServiceDependency elements. Then, only if your service depends on other services, add ServiceDependency elements for these services by name.


If this part is resolved, you will see ServiceInstall and ServiceControl are still incorrect. Name attributes, in particular, do not match. In your code example, it looks like you include leading spaces in many of your elements, and I would remove that. But even if it’s just errata from copy and paste, the installed LayoutSwitcher is different from the initial Layout Switch with some spaces in the middle.

This corresponds to error 0x80070424 mentioned in the comment as 0x424 = 1060, and net helpmsg 1060 :

The specified service does not exist as the installed service.

Make sure that the ServiceInstall / @ Name and ServiceControl / @ Name attributes match what you used when manually starting the service. (Note that if your manual test was on the command line, it is likely that any spaces were implicitly removed.)

+3
source

Source: https://habr.com/ru/post/1273046/


All Articles