Some services can't start or stop with Service Management Console. ex) DcomLaunch, SamSs
开发者_开发问答These services's stop button is disabled on Service Management Console. So, we can't stop the services.(Even if we have a Administrator account)
Is it possible? How can I do that?
Thanks in advance.
Your service ultimately calls SetServiceStatus to specify its status. Part of this is what controls it accepts. If you don't specify SERVICE_ACCEPT_STOP, the service cannot be shutdown. For managed code, you can set the CanStop property on ServiceBase.
Another possibility that allows a bit more finegrained control is to change the ACL on your service. MSDN has a sample article here. This is usually used if you want to allow non-admin users to be able to control when your service is running.
Please think very carefully if your service shouldn't be stopped - users should be in control of their machine and allowed to stop services at will.
精彩评论