.net 在 Windows 7 中安装/卸载服务:“错误 1001。指定的服务已被标记为删除”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4245766/
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-09-03 14:57:27  来源:igfitidea点击:

Installing/Uninstalling Services in Windows 7: "Error 1001. The specified service has been marked for deletion"

.netwindows-7windows-serviceswindows-installer

提问by Mas

I am currently developing a Windows Service in .NET 4.0, Visual Studio 2010, Windows 7-32bit. I have an installer project that does the installation for me. When I install the service, uninstall it, and try to install again, I get the following error:

我目前正在 .NET 4.0、Visual Studio 2010、Windows 7-32bit 中开发 Windows 服务。我有一个安装程序项目可以为我进行安装。当我安装服务、卸载它并尝试再次安装时,出现以下错误:

Error 1001. The specified service has been marked for deletion

错误 1001。指定的服务已被标记为删除

In Windows XP, the problem was that the Services.msc was open. Closing this window would fix this problem.

在 Windows XP 中,问题在于 Services.msc 已打开。关闭此窗口将解决此问题。

However, with Windows 7, the only way I can fix this is to restart. I tried closing all my programs, but the problem still persists.

但是,对于 Windows 7,我可以解决此问题的唯一方法是重新启动。我尝试关闭所有程序,但问题仍然存在。

Does anyone know how to fix this without restarting?

有谁知道如何在不重新启动的情况下解决这个问题?

Edit

编辑

I have not seen this problem since I stopped using the MSI installer, I use sc.exe instead, to install the services manually. I think this problem might be related to the combination of Visual Studio 2010 and MSI Installer Projects. However, I still don't know what was the culprit of this problem.It turns out that Process Explorer was the culprit.

自从我停止使用 MSI 安装程序后,我就没有看到这个问题,而是使用 sc.exe 来手动安装服务。我认为这个问题可能与 Visual Studio 2010 和 MSI 安装程序项目的组合有关。但是,我仍然不知道这个问题的罪魁祸首是什么。事实证明,Process Explorer 是罪魁祸首。

采纳答案by Mas

Short Answer

简答

  • Close Services.msc
  • Close Process Explorer
  • 关闭服务.msc
  • 关闭进程浏览器

Long Answer

长答案

After running into this problem again, I went to task manager and started shutting down processes. I eventually found the culprit, it was an internal corporate application used for managing software distribution. I shut it down, and the services were finally gone.

再次遇到这个问题后,我去了任务管理器并开始关闭进程。我最终找到了罪魁祸首,它是用于管理软件分发的内部企业应用程序。我关闭了它,服务终于消失了。

Update

更新

I also found that sometimes Process Explorer needs to be closed for deleted services to disappear.

我还发现有时需要关闭 Process Explorer 才能使已删除的服务消失。

回答by Ramya

I was facing the same problem on Windows 7 Ultimate edition. Installing the service after closing the Services.msc window solved my problem.

我在 Windows 7 Ultimate 版上遇到了同样的问题。关闭 Services.msc 窗口后安装服务解决了我的问题。

回答by Christopher Painter

Have you considered using a different MSI authoring tool such as Windows Installer XML? The advantage is it doesn't hide Windows Installer's underlying ServiceInstall / ServiceControl panels saving you from the pain of reinventing the wheel with fragile out of process InstallUtil code.

您是否考虑过使用不同的 MSI 创作工具,例如 Windows Installer XML?优点是它不会隐藏 Windows Installer 的底层 ServiceInstall / ServiceControl 面板,从而使您免于使用脆弱的进程外 InstallUtil 代码重新发明轮子的痛苦。

回答by Ben

I just solved this problem myself, in Windows 7.

我刚刚在 Windows 7 中自己解决了这个问题。

FWIW, turns out you can go to the "Services" tab, right-click on the offending service, choose "Go To Process", and kill as required.

FWIW,事实证明您可以转到“服务”选项卡,右键单击有问题的服务,选择“转到进程”,然后根据需要终止。

回答by rahul

I had the same issue with my windows service on my deployment server.

我的部署服务器上的 Windows 服务也有同样的问题。

Steps to solve problem:

解决问题的步骤:

  • Go to install/uninstall wizard in windows
  • Click on repair (which will fire custom action of setup)
  • After repair try to uninstall that windows service
  • it will uninstall perfectly
  • 转到 Windows 中的安装/卸载向导
  • 单击修复(这将触发设置的自定义操作)
  • 修复后尝试卸载该 Windows 服务
  • 它将完美卸载

Hope this will work for you.

希望这对你有用。