How exactly does the WiX 'Service Install'

2019-01-20 20:26发布

问题:

I have a problem with a web service that is installed and started with a .msi that is created with the WiX toolset.

The service can be installed and started on all the machines I tested so far (shown as running in the Services Manager) but on some machines it is not reachable (for example via a browser) and not shown in the list of listening ports on that machine (displayed with 'netstat -a').

I am trying to figure out what's going wrong but I am not really familiar with web service development and configuration. It's a third party service, thus I don't know how it works internally. A good starting point for me would be to find out, what exactly happens when a service is installed and started during the execution of the .msi-file. Maybe I could try to tackle the problem on a lower level then.

Below is my code in the ServiceInstall-Element:

<ServiceInstall
            Id="ServiceID"
            Type="ownProcess"
            Vital="yes"
            Name="ServiceName"
            DisplayName="ServiceDisplayName"
            Description="Lorem Ipsum"
            Start="auto"
            Account="LocalSystem"
            ErrorControl="normal"
            Interactive="no"
            Arguments="action=run">
    </ServiceInstall>

The argument is important - without it, the service won't start or run. Maybe someone else encounterd the same or a similar problem and can help me out.

Thanks already in advance - each hint is appreciated.


EDIT I (15.04.18):

As it might be a problem with the specific service, I will add some further information here:

It's a third party software called CryptoLicensing: http://www.ssware.com/cryptolicensing/cryptolicensing_net.htm

Part of this software is that specific program, that serves as a License Server and does the license registration, for example in a customer's network. The service can be run as a Windows application or installed and run as a Windows service. In both cases it should be listening on a (pre-)specified port on the installed machine. Whenever I start the .exe as an application, everything works as intended. The service is reachable (for example with the browser) and can be accessed from other machines in the network. When the .exe is installed and started as a service, it does not work as intended on every machine. For example if I install and start the service on my laptop, it is shown as running in the Services Manager, but is not reachable on its assigned URL (not even on the localhost) nor is the specific port displayed in the active listening ports, for example with 'netstat -a'. The service itself starts without any error messages and does not log any errors or exceptions as it seems to be running without any problems.

I contacted the vendor, but sometimes he doesn't reply quickly and he is not very specific in his replies.

Before asking the question I assumed that it was a problem with the Windows user rights and the WiX installer but during the discussion here I had the feeling that it might a problem with the service itself. I hope this 'new' piece of information helps in isolating and location the problem.

Thanks to everyone who helped so far!

回答1:

Hopefully not stating the obvious here, but WiX doesn't do much except populate the ServiceInstall table in the MSI file, so this is about why Windows Installer won't start the service. ServiceInstall table:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa371637(v=vs.85).aspx

Also, this isn't really about ServiceInstall - it's probably about the ServiceControl element in your WiX source, but it's not clear whether that's how you're starting it or if you're starting it manually later on. That does make a difference. What is the error message and where are you getting it, and is it a 1920 or 1921 error (in the context of ServiceControl).

The main reason a service will start on one system but not another is missing dependencies. If your service is C++ based (the post doesn't say) then there are probably dependencies on C runtimes, UCRT runtimes, MFC or ATL runtimes and so on.



回答2:

First: are you sure this service is intended to run as LocalSystem? (MSDN, SO).

Second: did you check the event logs in detail for anything obvious? If the service is good you should find a hint at least. Something to start with. I find that I sometimes miss the actual logs in the event viewer because it is so "crowded". My take on it: empty the log and stop and restart the service.


Something locking / blocking: If the service installs and runs OK I would suspect other factors such as firewalls (hardware & software), security software in general (anti-virus, malware scanners), network configuration issues (proxies, WINS, DNS and all the complexities involved in networking). Is the service trying to reach an UNC path?

Diverse Machines: What are the target machines? Are they virtual, are they physical, are they test machines, are they operative SOE machines in corporate networks? Are they the same OS version and edition?

Further Ideas: It is not quite related, but maybe skim this list of suggestions for debugging from another answer (I am not sure why it was down-voted, I think it is an OK list to inspire debugging ideas): Windows Application Startup Error Exception code: 0xe0434352 (maybe just skim the bolded words for ideas - Recommended).

sc.exe: And finally, perhaps check the sc.exe tool (Service Control) and see if it can provide you with some useful information for debugging.

  • sc.exe in the context of killing hung services (sample use).
  • sc.exe from MSDN

Some further links:

  • Windows Services Frequently Asked Questions (FAQ). Content seems to be up to date - at face value at least. These guys claim to be experts on services. I have no idea who they are.
  • Essential Tools for Windows Services: SC.EXE
  • Run Service Control (sc.exe) command on secure port