1

I'm trying to install a windows service using windows setup. Halfway through the setup hangs and never completes.

enter image description here

After a few minutes (4-5 mins) it throws the following error.

verify that you have enough privileges to start system services

enter image description here

The install.log is stuck at here.

enter image description here

Service1.cs class

public partial class Service1 : ServiceBase
    {

        public Service1()
        {
            InitializeComponent();
            ServiceName = "MSPmateAgentService";
        }

        protected override void OnStart(string[] args)
        {

        }

        protected override void OnStop()
        {

        }
        
    }

product.wxs file

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="*" Name="MSPmate Agent" Language="1033" Version="1.0.0.1" Manufacturer="MSPmate" UpgradeCode="2a2faae2-115e-4b45-aeeb-422663a2e357">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of MSPmate agent is already installed." />
    <MediaTemplate />
    <Feature Id="ProductFeature" Title="WixSetUpProject" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>
    <InstallExecuteSequence>
      <Custom Action="CustomActionFormId" Before="InstallFinalize">NOT Installed</Custom>
    </InstallExecuteSequence>
  </Product>
  <Fragment>
    <Binary Id="CustomActionBinary" SourceFile="$(var.WixCustomForms.TargetDir)$(var.WixCustomForms.TargetName).CA.dll" />
    <CustomAction Id="CustomActionFormId" Execute="immediate" Impersonate="no" BinaryKey="CustomActionBinary" DllEntry="PerformAuthentication" Return="check" />
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="MSPMATEAGENT" Name="MSPMATE AGENT" />
      </Directory>
    </Directory>
  </Fragment>
  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="MSPMATEAGENT">
      <Component Id="ProductComponent">
       <!-- <File Source="$(var.RMMSetUp.TargetPath)" /> -->

        <File Id='MSPmateAgentService' Name='MSPmateAgentService' DiskId='1' Source='$(var.RMMSetUp.TargetPath)' KeyPath='yes' Vital="yes"/>
        <ServiceInstall
          Id="ServiceInstaller"
          Type="ownProcess"
          Name="MSPmateAgentService"
          DisplayName="MSPmate Agent Service"
          Description="Agent service"
          Start="auto"
          Account="LocalSystem"
          Vital="yes"
          Interactive="no"
          ErrorControl="normal" />         
     
            <ServiceControl Id="StartService"
            Name="MSPmateAgentService"
            Start="install"
            Wait="no" />
        
            <ServiceControl Id="StopService"
            Name="MSPmateAgentService"
            Stop="uninstall"
            Remove="uninstall"
            Wait="yes" />

      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

am I missign anything here?

chamara
  • 12,649
  • 32
  • 134
  • 210
  • When it hangs, check in `Program Files\PMATE AGENT` to see if the windows service dll and its dependencies have been added into the folder. I suspect some of the dependencies might not be installed. I'm also not seeing where you have installed the config file. – peterpie Aug 02 '20 at 12:30
  • Service startup errors tend to be caused by **`missing runtimes`**, **`little misconfigurations`** in the config files or **`incomplete installation`** (some of your own files are missing), **`bitness issues`** (32 vs 64) and **`not-elevated MSI running`** (no UAC elevation for install). And a few other things. The answer below has more on debugging. – Stein Åsmul Aug 02 '20 at 17:43
  • How goes the battle? – Stein Åsmul Aug 14 '20 at 20:18

1 Answers1

0

In Brief: Service startup errors tend to be caused by missing runtimes, little misconfigurations in the config files or incomplete installation (some of your own files are missing), bitness issues (32 vs 64) and not-elevated MSI running (no UAC elevation for install). And a few other things.


A recent question on services with solution: Wix installer package containing a C++ Builder Windows service


Suggestions:

  • Go Manual: If you deploy this service manually (copy files in place manually), does it run properly on a clean box? To test for missing runtimes or misconfiguration. Configure service. VBScript: install service, other service tasks.
  • Verbose Log: It looks like you have one, but for others: make a proper verbose MSI log of the installation. Here is how: Different logging approaches. Symantec KDB.
  • No Wait: Have you tried to set the ServiceControl attribute "Wait" to "no" to allow the MSI to finish installing even if your service startup failed?
    • This should allow you to manually test the service startup via the Service control applet.
    • You can then also try Procmon.exe to check what happens during launch.
  • Debug Binaries: Could you deploy debug binaries and attach the debugger? I haven't tried this for years. There could be new obstacles: Interactive Services Detection Service Removed in Windows 10 (so no more Switching to Session 0).
  • Folder Diff: A quick trick: diff the folder that is working with the deployed folder that is not. For example between your main box and a virtual that has failed after clean installation.

Samples: WiX Service Installation samples:


Links:

Further Links:

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164