I've written a small windows service that I want to run daily on my Windows Server 2008. The service is written in C#.
But when running it on a commandline with:
net start Service1
I get the the following:
The Service1 service is starting........ The Service1 service could not be started.
The service did not report an error.
More help is available by typing NET HELP:SG 3534.
The weird thing is though, the service is still running, in the Services screen I still see it as starting untill it's fully started. When I try to stop the service afterwards I get:
The service could not be controlled in its present state.
More help is available by typing NET HELPMSG 2189
And then the service is stopped. Is there any way in solving this? I've already managed to debug the service without any problems, the code works. But during debugging the same thing still happens on the command console, while I'm still able to debug further.
It's like there is some kind of timeout on the onStart() method.. I have no idea.. I'm fairly new to Windows Services (this is my first one). I do write all my code in the onStart() method, maybe that's not the best idea, but I don't know where else to type it.
If someone could help I'd greatly appreciate it.
Click Start > Run > services. Locate and double click on the Windows Management Instrumentation service. The Windows Management Instrumentation service Properties window opens. Locate and change the Startup Type to Automatic. The Startup Type is changed.
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.
Why will my Windows Service not start? Make sure that the service's dependencies are running. Make sure that the service is not set to DISABLED. Sometimes when the service is set to log on as the local system account (default) for some reason, perhaps local permissions, it is unable to launch.
Restart the Windows Security Center Service Press Win + R to open the Run command dialog box. Type services. msc and press Enter to open the Services window. Locate the Windows Security Center, right-click on it, and then click Restart.
The OnStart event is used to launch a background thread that will take care of the processing. If the OnStart method finishes without error, the service manager assumes the service started successfully. As such, the OnStart should return as soon as possible.
The OnStop method is then used to stop the background processing. A successful OnStop tells the service manager that the service was closed without error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With