I try to remove a Windows Service with sc delete < service name>
, and encounter the following error: I> I try to use sc delete < service name>
Windows service, and encountered the following error:
[SC] DeleteService FAILED 1072: I> [SC] DeleteService FAILED 1072: b>
The specified service has been marked for deletion. I> specified service marked for deletion.
What I ‘ve already done: I> I have done: b> p>
-
Stopped the service, informational: I> obviously, service has been Stopped. The
sc queryex "< service name>"
gives the following result:sc queryex "< service name>"
gives the following results:SERVICE_NAME: Stub service TYPE : 10 WIN32_OWN_PROCESS STATE : 1 STOPPED WIN32_EXIT_CODE : 1067 (0x42b) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 PID : 0 FLAGS :
-
>Ensured that Microsoft Management Console was closed (
taskkill /F /IM mmc.exe
), I> Ensured that the Microsoft Management Console closed (taskkill /F /IM mmc.exe
),Ensured that the Event Viewer was closed, I> Ensured that the Event Viewer was closed, b>
1
2 3 Removed the key HKEY_LOCAL_MACHINE\\ \\ \\CurrentControlSet\\ \Services\\< service name> From the registry. I> deleted from the registry key HKEY_LOCAL_MACHINE \\ \ CurrentControlSet \\ Services \ < Service name & GT; .
Due to this removal, services.msc
still shows the service (with a name, but no status or startup type), but the description is “< MSC services.msc still shows the service (with name, but no status or startup type), but described as “< Unable to read description. Error Code: 2 >” . I> error code: 2>” . When we need to view the properties, “the system cannot find the file specified.” is shown five times. I> attempts to examine the property. .
The problem persists. I> problems still exist.
What is the next step? I> what do you do next?
h3> # 1 floor
reference: https://stackoom.com/question/1OH70/ how to solve the specified service has been marked for deletion – error p>
h3> # 2 floor
There may be several causes which lead to the service being stuck in “marked for deletion”.
-
SysInternals’ Process Explorer is opened. I>SysInternals’ Process Explorer. Closing it should lead to automatic removal of the service. I> Closing it will cause the service to be automatically deleted. b> p> li>
-
Task Manager is the opened. I> Task Manager has been opened.
-
Event Viewer is the opened. I> Event Viewer has been opened. Again, this is the same as the third point. I> .
Microsoft Management Console (MMC) is opened. I>Microsoft Management Console (MMC) has opened. To ensure all instances are closed, run taskkill /F /IM mmc.exe
.exe .exe I> To ensure that all instances are closed, run taskkill /F /IM mmc.exe
.
Services console is opened. This is the same as the previous point, since the Services console is hosted by mmc. I> This is the same as last, because the Services console is hosted by MMC. b> p> li>
The key HKEY_LOCAL_MACHINE\\ \Services\\{service name} exists. I> key HKEY_LOCAL_MACHINE\\ \CurrentControlSet\\ \\{service name} exists.
Someone else is logged into the server and has one of the previously mentioned applications.
An instance of Visual Studio used to debug the service is open. I> Visual Studio instance used to debug the service is open.
h3> # 3 floor
This can also be caused by leaving the Services console open. I> may also be caused by opening the service console. Windows won’t actually delete the service until it is closed. I> Windows does not actually delete the service until it is closed.
h3> # 4 floor
In my case, it was caused by unhandled exception while creating eventLog source. I> is caused by an exception that was not handled when the eventLog source was created. Use try catch to pin point the cause. I> Use try catch to identify the cause.
h3> # 5 floor
finds another thing to check – look it up in the task manager – if other users are connected to this box, even if they are “disconnected,” you must actually log them out to eventually delete the service.
h3> # 6 floor
Deleting registry keys as suggested above got my service stuck in the stopping state. I> Deleting registry keys as suggested above will stop my service. The following procedure worked for me: I> is useful for me: b>
open task manager > select services tab > select the service > right click and select “go to process” > Right click on the process and select End process I> open task manager > Select the service TAB & GT; Select service & GT; Right-click and select Go to Process & GT; Right-click the process, and select end process
Service should be gone after that I> after that Service should be gone