13

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
    – BDRSuite
    Commented Nov 4, 2014 at 7:14
  • 1
    I used that command without the services window even being open and it's still there. Commented Nov 4, 2014 at 7:20
  • 2
    I'm pretty sure that requires a reboot.
    – joeqwerty
    Commented Nov 4, 2014 at 13:56
  • But most of the time it removes it, why would it all-of-a-sudden require a reboot? Commented Nov 6, 2014 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
    Commented Aug 4, 2016 at 9:43

3 Answers 3

13

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
    Commented Aug 4, 2016 at 9:45
9

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).

2
  • 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
    Commented Nov 1, 2020 at 12:06
  • Thank you; I was looking at having to reboot after every time I tried to define my service, when the actual problem was only that I had the services panel open to verify the service was created and with the correct parameters. Saved me hours of time. Commented Dec 1, 2022 at 0:50
1

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

2
  • Prefer @dileep-kk's approach.
    – user692942
    Commented Aug 4, 2016 at 9:41
  • "Just reboot" -- And after 100 attempts to define a service for the first time that'll be 400 minutes of time I'll never get back. Commented Dec 1, 2022 at 0:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .