当系统上没有可执行文件时,如何卸载 Windows 服务? [英] How to uninstall a Windows Service when there is no executable for it left on the system?

查看:28
本文介绍了当系统上没有可执行文件时,如何卸载 Windows 服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果系统上没有可执行的 Windows 服务,我该如何卸载它?我无法运行 installutil -u 因为系统上没有可执行文件.我仍然可以在服务控制台中看到该服务的条目.

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 system. I can still see an entry for the service in the Services console.

出现这种状态的原因可能是msi包有问题没有正确删除服务,但是一旦服务处于这种状态如何修复?

The reason for this state is probably because of a problem in the msi package that does not remove the service correctly, but how do I fix it once the service is in this state?

推荐答案

您应该能够使用 sc.exe(我认为它包含在 Windows 资源工具包中)通过在管理员"命令中运行以下命令来卸载它提示:

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 <service name>

其中 是您在服务管理控制台中看到的服务本身的名称,而不是 exe 的名称.

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

您可以在 System 文件夹中找到 sc.exe,它需要管理权限才能运行.这篇 Microsoft 知识库文章中的更多信息.

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

或者,您可以直接调用DeleteService() api.这种方式有点复杂,因为您需要通过 OpenSCManager() 等等,但另一方面,它可以让您更好地控制正在发生的事情.

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.

这篇关于当系统上没有可执行文件时,如何卸载 Windows 服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆