6

I need to ensure that a particular service is always running on the computer. To do this, I use a bat with the command

sc start "servicename"

However, if the service has been marked for deletion, I get the above error. So, what is the proper way to solve this situation via bat?

Eduardo
  • 1,698
  • 4
  • 29
  • 48
  • Wouldn't `sc query` help you? – Squashman Oct 22 '15 at 17:24
  • Well... I just dont know how. – Eduardo Oct 22 '15 at 18:12
  • Did you try running `sc query servicename` to see what it outputs. – Squashman Oct 22 '15 at 18:13
  • Yes. I think I was not clear in saying that "I do not know how..." Consult the outputs does not help me, because my intention is to force the service to start, even though it was marked for deletion. I've tried removing the key "deleteflag" of the Windows registry, but even so, the sc command can not start the service. – Eduardo Oct 22 '15 at 18:16
  • Well I totally misunderstood your question. How do you know the service is not running and needs to be started? Why would you attempt to start a service if it is already running? Do you get the same error when you use the NET START command: `net start servicename` – Squashman Oct 22 '15 at 18:23
  • ultimately, you have to figure what is causing that error. Just doing a quick Google search will give you tons of information on it. But without knowing the WHO, WHAT, WHEN, WHERE, WHY of what happened on your server or what you did previously before this problem occured, it will be hard to troubleshoot. – Squashman Oct 22 '15 at 18:31
  • Related post - [How to solve “The specified service has been marked for deletion” error](https://stackoverflow.com/q/20561990/465053) – RBT Jun 21 '18 at 09:15

1 Answers1

5

This means, you have done commandline deletion of the service, however the services.msc is not reloaded with active services.

  • Try running delete service again, atleast you can make sure its marked for deletion or requires again (SC DELETE shortservicename)
  • Kill any .exe process associated with the service
  • Adding this before SC command most probably, this will force stop any processes

taskkill /F /IM service_name.exe

If this issue still not fixed, just restart the PC and try again. I had the same problem, and got resolved after PC restart.

Riyaz Hameed
  • 1,087
  • 12
  • 10