1

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?

sarnold
  • 102,305
  • 22
  • 181
  • 238
Skudd
  • 684
  • 2
  • 12
  • 28
  • Does it depend on the network adapter / connection? I have a problem where my network doesn't come up quickly enough, and that seems to stop services starting. – Peter K. Jun 26 '11 at 00:53
  • Peter, that's why I added the Dnscache and Netman services as dependencies. I read somewhere that they will not start until the network comes up. – Skudd Jun 26 '11 at 02:01

2 Answers2

1

Try using SetServiceStatus in your service to give it some time. And bear in mind, loading order is important.

nullpotent
  • 9,162
  • 1
  • 31
  • 42
  • Well, that having been said about loading order, what is the most commonly enabled service that's last to start? My only other idea for working around this is to add an entry to RunServices, but that seems quite hackish. – Skudd Jun 26 '11 at 02:27
1

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.

Skudd
  • 684
  • 2
  • 12
  • 28