10

I have installed a Windows service using the sc create method, then I later used the sc delete method to get rid of it, it then marked the service for deletion.

I made changes to the service and recompiled it, then I tried to recreate it using sc create but it said: The service has been marked for deletion So I thought I'd give it some time.

Now 1 day later and it's still marked for deletion. Can't do anything with the service.

I then tried the same thing using installutil with a different service and the first couple of times it added and removed it successfully, then it eventually also got stuck. Now I've got 2 services marked for deletion, installed using different methods and they were also marked for deletion using different methods.

If installutil and sc can't immediately remove my services, what other options do I have? (Excluding 3rd party components) Or is there a way I could forcibly remove these services?

6
  • 1
    Close the services window and delete the service by using the command sc delete service_name
    – vembutech
    Nov 4 '14 at 7:14
  • 1
    I used that command without the services window even being open and it's still there.
    – Anomaly
    Nov 4 '14 at 7:20
  • 2
    I'm pretty sure that requires a reboot.
    – joeqwerty
    Nov 4 '14 at 13:56
  • But most of the time it removes it, why would it all-of-a-sudden require a reboot?
    – Anomaly
    Nov 6 '14 at 9:38
  • @Anomaly In my case it was because the Visual Studio host was still locking some dependencies that stopped the service from being removed. Closing Visual Studio completely and using @dileep-kk's method worked for me.
    – user692942
    Aug 4 '16 at 9:43
10

The only way to remove such services is registry editing.

go to regedit and find

"HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services"

open the key which has your service name. That means the service name

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AdobeFlashPlayerUpdateSvc 

is for Adobe Flash player update service. You can see it in the corresponding displayname on the right panel of regedit.

Delete the key in the left panel and you are done. Also delete the files corresponding to it.

Make sure you are not deleting any wrong system services or else you will end up in trouble starting your machine.

1
  • 2
    Worked great. Remember that the service will not vanish from the Services.mvc application until the Service.mvc application has been closed and opened again. Refresh doesn't stop the service showing even though the registry key as gone probably due to caching.
    – user692942
    Aug 4 '16 at 9:45
5

Using sc.exe delete srvname will postpone the service deletion if it's: 1) running or 2) the "services" management console is open. Making sure the service is stopped and closing the "services" console deletes the service immediately (Windows 10 Pro 10.0.18363).

1
  • Can confirm, this was my issue. I wish this easy and good practice solution would be more known than those requiring heavy registry editing or similar measures.
    – Akito
    Nov 1 '20 at 12:06
2

"marked for deletion" means it will be deleted at next reboot. Just reboot your server, it will automatically disappear.

1

Not the answer you're looking for? Browse other questions tagged or ask your own question.