Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Service won't automatically start after reboot [duplicate]

My automatically starting windows service fails to start only on reboot. I have a windows service created in C# and installed via a Wix created installer. The service is set up to start automatically. The service is installed and run under the NT AUTHORITY\NETWORK SERVICE. When the service is started, it first makes an external web services call.

In Windows 7 I can set the service to be Automatic - Delayed start and the service will start on reboot no problem. However, this option is not available in Windows XP, and when set to Automatic start, the service fails due to

A timeout was reached (30000 milliseconds) while waiting for the MyService service to connect.

If I try to start manually after the login process, the service starts fine, it is only when the service tries to auto start on reboot that there is an issue, leading me to believe there are dependency services that I need to add to my service for it to start correctly.

Can anyone point me to the correct dependencies or an alternative approach?

like image 230
Jared Knipp Avatar asked Sep 15 '10 17:09

Jared Knipp


People also ask

Why service is not starting automatically?

If your service StartType is set to Automatic, but the service is not running after a reboot, then either your service has a dependency on another service that is not starting correctly, or your service's own startup code is failing and ends up stopping the service.

How can you make a service run automatically after boot in Windows?

Go to start type services. msc and press enter. On the services list that opens up, right click on the service and select Properties. The dialog that opens has an option 'Automatic' for starting your service.

How do I force a service to start?

Start service Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to start a service and press Enter: net start "SERVICE-NAME" In the command, replace "SERVICE-NAME" for the name or display name of the service.

How do I start a service that won't start?

1] Check Services Startup type msc and hit Enter to open the Services Manager. Here you can set its startup type to Automatic, Delayed, Manual or Disabled. Check if the specific service with whom you are facing problems is not set to Disabled. See if you can start it manually by clicking on the Start button.


1 Answers

You likely have a race condition with a dependency. You could probably patch around this by configuring your service to have a dependency on another service ( say tcp/ip ) but what I'd really do is rewrite your service to not need to make this call during the criticial execution path of startup. It should instead periodically attempt to make the webservice call at a later point and log useful messages or send messages to a taskbar utility or similar if there is a problem that needs to be addressed.

like image 121
Christopher Painter Avatar answered Oct 06 '22 00:10

Christopher Painter