How to Force Delete a Windows Service When “SC Delete” Fails with Access Denied (5)


2 views

When you encounter the "OpenService FAILED 5: Access denied" error while attempting to remove a Windows service, it typically indicates one of these scenarios:

  • The service is marked for deletion but stuck in pending state
  • Your account lacks sufficient privileges (not running as Administrator)
  • Service control manager has locked the service database
  • The service executable is currently running or being used

First, verify the service status with:

sc queryex service_name

Check if the SERVICE_ACCEPT_STOP flag is set. If not, the service might be protected. Also ensure you're running the command prompt as Administrator (right-click > Run as administrator).

Method 1: Using SC with Elevated Privileges

Sometimes simply running SC with proper elevation solves the issue:

sc stop service_name
sc delete service_name

Method 2: Manual Registry Removal

Warning: Editing registry incorrectly can damage your system. Always back up first.

reg delete HKLM\SYSTEM\CurrentControlSet\Services\service_name /f

You may need to delete the registry key in these locations:

  • HKLM\SYSTEM\CurrentControlSet\Services
  • HKLM\SYSTEM\ControlSet001\Services
  • HKLM\SYSTEM\ControlSet002\Services

Method 3: Using PowerShell with Force

PowerShell often provides better control:

$service = Get-WmiObject -Class Win32_Service -Filter "Name='service_name'"
$service.delete()

Or alternatively:

Remove-Service -Name "service_name" -Force

Method 4: Process Explorer Technique

For stubborn services locked by running processes:

  1. Download Process Explorer from Microsoft
  2. Find the service executable
  3. Kill the process tree
  4. Retry service deletion

In rare cases where standard methods fail, try these steps:

sc config service_name start= disabled
net stop service_name /y
sc delete service_name

For services that auto-restart, you might need to use:

sc failure service_name reset= 0 actions= ""/""/""/""/""

After successful deletion, check for residual files:

  • Service executable in System32 or Program Files
  • Event log entries related to the service
  • Scheduled tasks associated with the service

Reboot your system to ensure all changes take effect and the service is completely removed from memory.


When trying to remove a Windows service using the sc delete command, you might encounter the frustrating "OpenService FAILED 5: Access is denied" error. This typically occurs when:

  • The service is currently running or in a locked state
  • Your user account lacks sufficient privileges
  • The service is protected by Windows Resource Protection
  • Antivirus software is interfering with service removal

Before attempting force removal, try these standard steps:

sc stop ServiceName
sc config ServiceName start= disabled
sc delete ServiceName

Method 1: Using PowerShell with Admin Rights

PowerShell often provides more control over service management:

$service = Get-WmiObject -Class Win32_Service -Filter "Name='ServiceName'"
$service.delete()

Method 2: Registry Editor Approach

Warning: Editing the registry can be dangerous. Always back up first.

  1. Open Registry Editor (regedit)
  2. Navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
  3. Find and delete the service key
  4. Reboot your system

Method 3: Using Process Explorer

Sysinternals tools can help identify what's locking the service:

  1. Download Process Explorer from Microsoft
  2. Run as Administrator
  3. Find the service process
  4. Use the "Handle" feature to identify locks
  5. Terminate the process if safe to do so

For stubborn services protected by Windows:

takeown /f C:\Windows\System32\servicename.exe
icacls C:\Windows\System32\servicename.exe /grant administrators:F
sc delete servicename
  • Always stop services before deletion attempts
  • Use Administrator Command Prompt
  • Check for dependent services
  • Consider using the Windows Installer Cleanup Utility for MSI-installed services