25

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:

Error 1001. The specified service has been marked for deletion

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

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.

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.

Michael Paulukonis
  • 8,540
  • 5
  • 46
  • 66
Mas
  • 4,346
  • 5
  • 34
  • 54
  • 2
    Use Taskmgr.exe, Processes tab and start killing processes one by one until you find the one that still has the registry keys opened. – Hans Passant Nov 22 '10 at 13:26
  • I have stopped using MSI to install the service, but instead install manually using sc.exe. Since then, I have not encounted this problem. It seems that this problem might be related to MSI projects, and possibly visual studio. – Mas Jan 13 '11 at 11:16
  • Yep its Service Explorer (services.msc) that messes up. – TheVillageIdiot Jun 26 '13 at 23:55

5 Answers5

42

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

Ramya
  • 657
  • 2
  • 8
  • 12
24

Short Answer

  • Close Services.msc
  • Close Process Explorer

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.

Mas
  • 4,346
  • 5
  • 34
  • 54
6

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.

Christopher Painter
  • 52,390
  • 6
  • 60
  • 97
  • Thanks for that good tip. Currently, my needs are very simple so I am fine with using the Installer Project that comes with VS. I'm just stuck with this annoying problem. Currently, I'm working around this problem by manually installing and uninstalling using InstallUtil.exe. – Mas Nov 23 '10 at 08:44
  • Feel free to contact me when you get sick of 1001 error messages ( even during silent installs ). I've got 14 years of experience writing installers and I can say with authority that InstallUtil is horrible. A postbuild script to author the ServiceInstall and ServiceControl tables would be a much better solution. – Christopher Painter Nov 23 '10 at 14:13
  • +1. I should say that I fell into this hole myself. When I relied on InstallUtil in my installation, 70% of reported problems were related to its errors. And I could reproduce and troubleshoot only few of them... – Yan Sklyarenko Mar 01 '11 at 12:31
1

I just solved this problem myself, in 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.

Ben
  • 47,286
  • 44
  • 159
  • 208
0

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

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

Hope this will work for you.

rahul
  • 1
  • 1