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

29,871

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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.

Share:
29,871

Related videos on Youtube

Mas
Author by

Mas

Updated on July 09, 2022

Comments

  • Mas
    Mas almost 2 years

    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.

    • user1703401
      user1703401 over 13 years
      Use Taskmgr.exe, Processes tab and start killing processes one by one until you find the one that still has the registry keys opened.
    • Mas
      Mas over 13 years
      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.
    • TheVillageIdiot
      TheVillageIdiot almost 11 years
      Yep its Service Explorer (services.msc) that messes up.
  • Mas
    Mas over 13 years
    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.
  • Christopher Painter
    Christopher Painter over 13 years
    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.
  • Yan Sklyarenko
    Yan Sklyarenko about 13 years
    Great, but this doesn't mean that on another target machine it won't shoot... I would strongly recommend you to consider Christopher's suggestion.
  • Yan Sklyarenko
    Yan Sklyarenko about 13 years
    +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...
  • Mas
    Mas about 13 years
    I'm no longer using the MSI installer. I now do installation of services using sc.exe in script.
  • SWB
    SWB almost 13 years
    Process Explorer was the culprit in my case.
  • Michael Paulukonis
    Michael Paulukonis over 12 years
    Ugh. Same here. WHY, ProcessExplorer, WHY WHY WHY?!?!?!?