C# Windows 服务给出描述:<无法读取描述错误代码 2>

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13153214/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 01:46:23  来源:igfitidea点击:

Windows Service is giving Description: <Failed to read description error code 2>

c#windows-services

提问by Elvin

I have tired to uninstall a disabled windows service through registry It is removed from registry but it is still showing in Services.msc with

我已经厌倦了通过注册表卸载禁用的 Windows 服务 它已从注册表中删除,但它仍显示在 Services.msc 中

Description: Failed to read description error code 2

描述:无法读取描述错误代码 2

回答by CoreTech

Follow these instructions to remove the service. Make sure that you use the service's name, not its display name!

按照这些说明删除服务。确保您使用服务的名称,而不是其显示名称!

The service shouldn't show up in Services.msc after that, but you may still have old items in the Event Viewer that can't display their description properly.

之后该服务不应出现在 Services.msc 中,但事件查看器中可能仍有旧项目无法正确显示其描述。

回答by ekta

Intuition/How you got there -

直觉/你是如何到达那里的 -

I am assuming you did either or both of these to land in this error message. a.Deleted the key manually from registry by HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services and deleted the service from here)

我假设您执行了其中一项或两项操作以显示此错误消息。a.通过HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services手动从注册表中删除密钥并从这里删除服务)

b.This service was in "automatic" start - so on deleting the service was somehow mislead in "starting automatically" - and hence produced this code Failed to read description error code 2 . Here's why - You should have stopped the service, or changed it to "Start manually" before doing this.

b.此服务处于“自动”启动状态-因此删除该服务会在“自动启动”中以某种方式误导-因此产生此代码 Failed to read description error code 2 。这就是原因 - 在执行此操作之前,您应该停止该服务,或将其更改为“手动启动”。

How to fix it and what worked for me -

如何修复它以及对我有用的方法 -

[1]Go to cmd prompt in admin mode (meaning select cmd -> "Run as Administrator")

[1]在管理员模式下进入cmd提示符(意思是选择cmd->“以管理员身份运行”)

You should be in "C:/windows/system32/"[This should come up be default if you are in admin mode, as above] Type -> sfc /scannowAfter this the scan will begin and the following logs will appear --

你应该在"C:/windows/system32/"[如果你在管理员模式下,这应该是默认值,如上] 键入 -> sfc /scannow在此之后,扫描将开始并会出现以下日志-

Beginning system scan. This process will take some time.

Beginning verification phase of system scan. Verification 100% complete. Windows Resource Protection found corrupt files but was unable to fix some of them. Details are included in the CBS.Log windir\Logs\CBS\CBS.log. For example C:\Windows\Logs\CBS\CBS.log

The system file repair changes will take effect after the next reboot.

开始系统扫描。这个过程需要一些时间。

开始系统扫描的验证阶段。验证 100% 完成。Windows 资源保护找到了损坏的文件,但无法修复其中的一些。详细信息包含在 CBS.Log windir\Logs\CBS\CBS.log 中。例如 C:\Windows\Logs\CBS\CBS.log

系统文件修复更改将在下次重新启动后生效。

[2]Finally reboot your system ! And the service will no longer appear in services.msc.

[2]最后重启你的系统!并且该服务将不再出现在 services.msc 中。

回答by Murugan Shivananantha Perumal

This error indicates that the service description key in registry [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services] is deleted but the service description in memory is not cleared yet. To resolve this, Reboot the PC / Server and try again.

此错误表示注册表 [ HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services]中的服务描述键被删除,但内存中的服务描述尚未清除。要解决此问题,请重新启动 PC/服务器并重试。

回答by Hasan Badshah

I also deleted my service using windows registry.

我还使用 Windows 注册表删除了我的服务。

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services]

In my case i didn't restart my PC, I just restart the task manager and deleted service was no more there.

在我的情况下,我没有重新启动我的电脑,我只是重新启动了任务管理器,并且已删除的服务不再存在。

回答by Sanjeev

  1. Open cmd with "Run as administrator"
  2. Run at cmd: sc delete "service name which you want to delete"
  1. 使用“以管理员身份运行”打开cmd
  2. 在cmd下运行: sc delete "service name which you want to delete"

回答by Maria

I tried almost all of the solutions listed above. What finally worked for me was deleting it from the Task Manager.

我尝试了上面列出的几乎所有解决方案。最终对我有用的是从任务管理器中删除它。

I am using Apache's ProcRun application to wrap my Java code in a windows service. While the command line details in the Task Manager helped identify the process running the service. Just deleting that process fixed the issue!

我正在使用 Apache 的 ProcRun 应用程序将我的 Java 代码包装在 Windows 服务中。虽然任务管理器中的命令行详细信息有助于识别运行服务的进程。只需删除该过程即可解决问题!