How to uninstall a Windows Service when there is no executable for it left on the system?

前端 未结 7 2167
陌清茗
陌清茗 2021-01-29 18:14

How do I uninstall a Windows Service when there is no executable for it left on the system? I can not run installutil -u since there is not executable left on the s

7条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 18:43

    You should be able to uninstall it using sc.exe (I think it is included in the Windows Resource Kit) by running the following in an "administrator" command prompt:

    sc.exe delete 
    

    where is the name of the service itself as you see it in the service management console, not of the exe.

    You can find sc.exe in the System folder and it needs Administrative privileges to run. More information in this Microsoft KB article.

    Alternatively, you can directly call the DeleteService() api. That way is a little more complex, since you need to get a handle to the service control manager via OpenSCManager() and so on, but on the other hand it gives you more control over what is happening.

提交回复
热议问题