开发者

Actually **Delete** service while services.msc is open

I've noticed that sc delete ServiceKeyName won't work if services.mmc is open. It marks it for deletion (whatever! That just means it doesn't do what I want as far as I'm concerned).

My question is: Is there a method for deleting a service that will work regardless whether services.mmc is open or not? or should I ensure any instances of services.mmc are closed before I try to delete it?

I'm looking into using DeleteService

http://msdn.microsoft.com/en-us/library/ms682562%28v=VS.85%29.aspx

http://msdn.microsoft.com/en-us/library/ms682571%28v=VS.85%29.aspx

But it also talks of closing handles and similar excuses for why it cannot do what the user has asked to be done immediately. So开发者_JAVA技巧 if DeleteService is going to also require that services.mmc is closed, then I'll stick to sc delete and kill process on services.mmc instead of implementing DeleteService. I want a method that does what it advertises (no excuses - no waiting for anything).


In order to achieve this you would need the services MMC snap in to close and reopen its handle to the service control manager. It won't do this and thus you have to accept the behaviour as is.


I ran into the same thing. If you pass the command -remove after the service name, it will remove it even if the services.mmc is is open. Also stop the service first via command line net stop 'servicename' prior to the -remove.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜