Services can be stopped and started using two commands in Command Prompt Shell.
- net start service "some service"
- sc start "some service"
what is the difference between these commands?
4 Answers
In Windows NT, both commands access the same Service Manager. The difference is mainly in the user-visible part:
netis older – from the days of MS-DOS and OS/2, in fact.sconly appeared with Windows NT (not sure which version).netcan only start, stop and pause services.schas more advanced controls, can query state, create and delete services, change their configuration and security:sc config beep start= demandnetonly works locally.sccan be used over the network:sc \\snow start rpcapdnetaccepts display names:net start "Windows Firewall"scalways requires a service name:sc start SharedAccess
Grawity's answer is certainly helpful, but I found a fundamental difference between these commands detailed on . In particular, this page notes that these two commands differ in their timing: "net" is synchronous and "sc" is asynchronous.
4SC sends the control to the service and then returns to the command prompt. This typically results in SC START returning the service in a state of START_PENDING. NET START will wait for the service it is starting to come to a fully started state before it returns control at the command prompt.
...
[L]ike SC START, SC STOP does not wait for the service to come to a stopand will there for often return STOP_PENDING for many service stop operations. NET STOP on the other hand will wait on the service to stopbefore it returns to the command prompt.
...
NET and SC have different ideas of what they consider to be success conditions. The question SC asks to determine if it was successful is, “Did I successfully send a stop control to the service?” If it did, regardless of whether the service stopped, then I satisfied the successful condition. NET asks the question, “Did the service I attempted to stop, return that it stopped successfully?” If it did, then it satisfied the condition. If it didn’t, no matter what the reason, then NET fails the successful condition
For what its worth, I've found sc start/stop to be more reliable than net start/stop. Sometimes net start/stop caused the service to be stuck in a Starting/Stopping state whereas this has never occurred to me yet with sc start/stop. The net start/stop symptom tends to occur more often if the service was killed (via taskkill), e.g. attempting to start the service with net start after taskkill.
Left to say that if the OnStart() routine of a service takes too long, NET START sends a stop command to the service and returns the following error:
The ServiceName service is starting........
The ServiceName service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534.
This happens although the service has been started and stopped successfully !!
I also found this post here, that might be interesting:Service could not be started