4
votes

I have created a windows service with Automatic Start Type and install it in my system successfully but it does not start until i restart my system. Details: yesterday i have create and install my service and then restart my windows so the service started successfully. but the problem occurred today when i boot my windows and opened the services list of windows from Control Panel\Administrative Tools\Services and selected my service i saw that it did not start automatically. what is my mistake?

3
Take a look at the Windows Event Log whether any errors related to your service were logged. - Uwe Keim
Are you passing parameters from the command line to your service when you start it? - Icarus
@Icarus,I did not start my windows service by Command line because i want that my service starts automatically. - M_Mogharrabi
@Uwe Keim,i have checked Event Logs from visual studio and it just said that This service can not start. - M_Mogharrabi

3 Answers

3
votes

Assuming the service is set to 'Automatic' as the startup mode, and that it's state is not 'Started', then there will be at least one message about why the service did not start in the System Event Log.

Typical reasons are that the service didn't start quickly enough (Service Controller imposes a time limit on how quickly services must respond to the 'Start' message) or that the service depended on another service which wasn't yet available (check your service dependencies) or that your service simply failed due to a software error (e.g. some resource it needs could not be found).

Find the error in the event log, and you'll have a much better idea of why your service hasn't started.

3
votes

As your service was running fine yesterday but not today. Checking all its dependencies would be my first suggestion.

In your Start-> Run, type services.msc . It's a shortcut to open the services console.

Then Right click on your service , if it is listed there, click on Properties on this popup menu.

Open the Dependency tab (4th tab) , check if your service depends on some other service and that dependency is running.

Regards,

bhupendra

0
votes

Example:

SC.exe config "ServiceName" start= auto