SC Borrar No Borrar Servicio
Frecuentes
Visto 29,505 veces
34
So I'm running Windows Server 2008 R2 Standard and am trying to delete a service with 'sc delete <myservicesname>
' and the command seems to execute without complaint, however, when I check the services list after running the command, the service is still there.
¿Alguna idea?
4 Respuestas
120
sc in PowerShell is Set-Content; so if you are running in PowerShell, you likely have a file called 'delete' with your service's name as its content
If this is indeed your issue, use
sc.exe delete servicename
Respondido el 20 de diciembre de 19 a las 10:12
Helped me out as well. Thanks - Bennie van der Walt
16
Service can be marked for deletion, but may not be deleted immediately, since something holds it. See this answer for possible holders: https://stackoverflow.com/a/20565337/1943849
In my case, I just closed the Computer Management
ventana
Respondido el 29 de Septiembre de 17 a las 14:09
Most unexpected fix, there is no indication a service is marked for deletion - muy
1
Make sure to stop the service first then run the sc delete command. It will take care of closing any running process.
Respondido 18 Oct 19, 21:10
0
You can do something like this in PowerShell, although Remove-Service cmdlet is only available in PowerShell versions 6.0 and up
$SERVICE_NAME
get-service | Where-Object {$_.Name -eq $SERVICE_NAME} | Stop_Service
try{
if((Get-Host | Select-Object -ExpandProperty Version).Major -ge 6){
Remove-Service -Name $SERVICE_NAME
}else{
sc.exe delete $SERVICE_NAME
}
}catch{
Write-Output $_.exception.message
}
You can find the docs for Remove-Service cmdlet AQUÍ
Respondido 27 Oct 22, 20:10
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas windows service windows-server-2008 or haz tu propia pregunta.
I found Brian's answer correct. - JN01
Brian's answer also helped me out, since I was using powershell, and sc just looked like it did nothing. - Bennie van der Walt