Search code examples
soapwindows-serviceswminsiswmi-service

Windows service fails to start on boot


Before I get into the text of this, please be aware that I have already tried the following:

  • Setting the service dependencies
  • Setting an extended timeout

Now, that having been said, you can probably guess what my problem is: My Windows service is failing to start on boot, yet I can start it just fine manually from the services manager. The event log shows that it did attempt to start on boot, but it failed to respond in a timely manner.

The service is nothing extraordinary, in that it only hits a SOAP endpoint, runs some system commands, and runs some WMI queries. I have set the service to depend on the DNS service and the WMI service, yet it's still failing to start (timing out), which tells me something else is keeping it from running.

I am registering the service using the NSIS SimpleSC plugin, using the following options:

Service Type: SERVICE_WIN32_OWN_PROCESS 
Start Type: SERVICE_AUTO_START 
Dependencies: Winmgmt, Netman, Eventlog, Dnscache
User Name: LocalSystem

What am I missing?


Solution

  • Turns out this issue was at a level lower than the start order or that sort of thing. It had to do with some initialization code I had in my service's constructor. Once I refactored it to move that code outside of the constructor, all was working well.

    Thank you to @AljoshaBre and @Peter K. for their help.