What's Actually Happening

You're trying to start or stop a Windows service, but it's stuck in a pending state. The service shows "Starting" or "Stopping" in Services console but never completes the operation. The service doesn't respond to start/stop commands, and you can't restart it or terminate it through normal means.

This is a common Windows issue where the service control manager (SCM) loses communication with the service process, or the service encounters an error during startup/shutdown that prevents proper state transitions. The service becomes unresponsive, and the SCM continues waiting indefinitely.

The Error You'll See

Windows service stuck issues manifest in several ways:

```powershell # Service shows "Starting" indefinitely Get-Service MyService Status Name DisplayName ------ ---- ----------- Starting MyService My Service Application

# Service shows "Stopping" indefinitely Get-Service MyService Status Name DisplayName ------ ---- ----------- Stopping MyService My Service Application

# Error when trying to stop stuck service Stop-Service MyService Stop-Service : Service 'My Service (MyService)' cannot be stopped due to the following error: Cannot stop service MyService on computer '.'.

# Error when trying to start Start-Service MyService Start-Service : Service 'My Service (MyService)' cannot be started due to the following error: Another service is already running with the same name.

# Services console shows "Starting" or "Stopping" with grayed out buttons

# sc.exe command hangs sc stop MyService # Hangs indefinitely

# When trying to kill service process taskkill /F /IM MyService.exe ERROR: The process "MyService.exe" with PID 1234 could not be terminated. Reason: Access is denied.

# Event log shows service timeout Event ID 7011: A timeout was reached (30000 milliseconds) while waiting for the MyService service to connect.

# Event log shows service control error Event ID 7031: The MyService service terminated unexpectedly.

# Service recovery options triggering but service still stuck

# PowerShell timeout error Start-Service : Service 'MyService' start failed. At line:1 char:1 + Start-Service MyService + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service], ServiceCommandException + FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands.StartServiceCommand ```

Additional symptoms: - Services.msc console becomes unresponsive - Reboot stuck on "Stopping services" - Service shows as "Disable" but can't be enabled - Other services depending on stuck service won't start - Service process still running but unresponsive - High CPU usage from service process - Can't uninstall service - Service recovery options don't work

Why This Happens

  1. 1.Service Thread Deadlock: The service's main thread is deadlocked during initialization or shutdown. It can't complete the start/stop sequence and never signals completion to SCM.
  2. 2.Service Timeout: The service takes longer than the configured timeout (default 30 seconds) to start or stop. SCM gives up waiting but doesn't properly handle the timeout, leaving the service in pending state.
  3. 3.Missing Service Executable: The service executable file was deleted or moved. When SCM tries to start the service, it can't find the executable but also can't properly fail.
  4. 4.Service Process Hung: The service process is running but unresponsive - waiting on network resources, database connections, or other blocking operations.
  5. 5.Dependency Chain Issues: A service depends on another service that's stuck, creating a chain of stuck services waiting for each other.
  6. 6.Corrupted Service Registry: The service's registry keys are corrupted, preventing proper state management by SCM.
  7. 7.Service Account Issues: The service runs under a user account that's locked, password expired, or has insufficient permissions.
  8. 8.Pending Restart from Update: Windows update requires service restart but the restart process got stuck.

Step 1: Identify Stuck Services

Find all services that are stuck in pending states.

```powershell # List all services with their status Get-Service | Where-Object { $_.Status -eq "StartPending" -or $_.Status -eq "StopPending" }

# Get detailed service info Get-WmiObject Win32_Service | Where-Object { $_.State -like "*Pending*" } | Select-Object Name, State, ExitCode

# Using sc.exe to query sc query type= service state= all | find "PENDING"

# Check specific service sc query MyService

# Get service process ID Get-WmiObject Win32_Service -Filter "Name='MyService'" | Select-Object Name, ProcessId, State

# Or use: (Get-CimInstance Win32_Service -Filter "Name='MyService'").ProcessId

# List all services with their process IDs Get-WmiObject Win32_Service | Where-Object { $_.ProcessId -gt 0 } | Select-Object Name, ProcessId, State

# Check service configuration sc qc MyService

# Get service details including recovery options Get-Service MyService | Select-Object *

# Check services that depend on this service Get-Service MyService -DependentServices

# Check services this depends on Get-Service MyService -RequiredServices

# View services in PowerShell with more detail Get-CimInstance Win32_Service | Where-Object { $_.State -match "Pending" } | Format-Table Name, State, DisplayName, ProcessId ```

Step 2: Wait and Use Normal Commands

First, try standard approaches with extended timeout.

```powershell # Wait longer for service to complete operation # Default timeout is 30 seconds, try waiting more:

# Wait and retry $service = Get-Service MyService $timeout = 120 # seconds $startTime = Get-Date

while ($service.Status -match "Pending" -and ((Get-Date) - $startTime).TotalSeconds -lt $timeout) { Start-Sleep -Seconds 5 $service.Refresh() Write-Host "Current status: $($service.Status)" }

# Try graceful stop with longer timeout Stop-Service MyService -Force -ErrorAction SilentlyContinue

# Use sc.exe with explicit timeout sc stop MyService # Then wait

# Check if service responds to control commands sc control MyService 1 # SERVICE_CONTROL_STOP

# Try from elevated PowerShell Start-Process powershell -Verb RunAs -ArgumentList "-Command Stop-Service MyService -Force"

# Use net stop net stop MyService

# Or net start net start MyService

# Check if computer needs restart # Sometimes only a reboot will clear the stuck state

# Check Event Log for service errors Get-EventLog -LogName System -Source "Service Control Manager" -Newest 10 | Where-Object { $_.Message -like "*MyService*" } ```

Step 3: Kill the Service Process

Terminate the unresponsive service process.

```powershell # Get service process ID $service = Get-WmiObject Win32_Service -Filter "Name='MyService'" $processId = $service.ProcessId

Write-Host "Service Process ID: $processId"

# If process ID is 0, service isn't running if ($processId -eq 0) { Write-Host "Service is not running any process" }

# Kill the process Stop-Process -Id $processId -Force

# Or using taskkill taskkill /F /PID $processId

# If you know the executable name: taskkill /F /IM MyService.exe

# Kill all instances taskkill /F /IM MyService.exe /T

# After killing, check service status Get-Service MyService

# Service might now show as Stopped # Try starting again: Start-Service MyService

# If killing process doesn't work, kill related processes: Get-Process | Where-Object { $_.Name -like "*MyService*" } | Stop-Process -Force

# Check for svchost hosting multiple services: tasklist /SVC | findstr MyService

# If service runs in svchost, you need to be careful # Killing svchost will kill multiple services ```

Step 4: Force Service State via Registry

Modify service state directly in registry.

```powershell # WARNING: Editing registry can cause system instability # Always backup before making changes

# Open registry editor regedit

# Navigate to service key: # HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService

# In PowerShell: $serviceKey = "HKLM:\SYSTEM\CurrentControlSet\Services\MyService"

# Check current values: Get-ItemProperty $serviceKey

# Check the "Start" value: (Get-ItemProperty $serviceKey).Start

# Start values: # 2 = Automatic # 3 = Manual # 4 = Disabled

# Check the "DelayedAutostart" value if applicable

# If service is stuck, try: # 1. Stop the service via registry Set-ItemProperty -Path $serviceKey -Name "Start" -Value 4 # Disabled

# 2. Reboot the computer

# 3. After reboot, re-enable: Set-ItemProperty -Path $serviceKey -Name "Start" -Value 2 # Automatic

# Or use sc.exe config: sc config MyService start= disabled # Reboot sc config MyService start= auto

# Check for corrupted Parameters subkey: Get-ItemProperty "$serviceKey\Parameters" -ErrorAction SilentlyContinue

# Export service key for backup: reg export "HKLM\SYSTEM\CurrentControlSet\Services\MyService" C:\backup\MyService.reg ```

Step 5: Use sc.exe to Force Control

Use sc.exe commands to manipulate service state.

```powershell # Query service status sc query MyService

# Get extended info sc queryex MyService

# Try to stop service sc stop MyService

# If stuck, try sending raw control codes: # SERVICE_CONTROL_STOP = 1 sc control MyService 1

# SERVICE_CONTROL_PAUSE = 2 sc control MyService 2

# SERVICE_CONTROL_CONTINUE = 3 sc control MyService 3

# SERVICE_CONTROL_INTERROGATE = 4 sc control MyService 4

# Delete service (use with caution!) sc delete MyService

# Recreate service after deleting: sc create MyService binPath= "C:\Path\To\MyService.exe" start= auto DisplayName= "My Service"

# Check service config: sc qc MyService

# Modify service failure actions: sc failure MyService reset= 86400 actions= restart/5000/restart/5000/restart/5000

# Reset service to default state: sc failure MyService reset= 0 actions= ""

# Check service trigger info: sc qtriggerinfo MyService

# Disable service: sc config MyService start= disabled

# Enable service: sc config MyService start= demand # Manual sc config MyService start= auto # Automatic

# Force service to accept commands: sc sdset MyService D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU) ```

Step 6: Restart Service Control Manager

Restart the SCM without rebooting the entire system.

```powershell # SCM runs as a system process # Cannot be directly stopped, but we can try:

# Kill services.exe process (will likely force reboot): # WARNING: This will likely cause system reboot! # taskkill /F /IM services.exe

# Safer approach: restart in safe mode

# Use msconfig to set safe boot: msconfig

# Or via bcdedit: bcdedit /set {default} safeboot minimal

# Reboot shutdown /r /t 0

# In safe mode, the stuck service should be stopped # Then disable it:

sc config MyService start= disabled

# Reboot normally: bcdedit /deletevalue {default} safeboot shutdown /r /t 0

# Re-enable service: sc config MyService start= auto ```

Step 7: Use PowerShell CIM Methods

Use WMI/CIM methods for more control.

```powershell # Get service CIM instance $service = Get-CimInstance -ClassName Win32_Service -Filter "Name='MyService'"

# Check current state $service.State

# Try to stop using CIM method Invoke-CimMethod -InputObject $service -MethodName StopService

# Try to start using CIM method Invoke-CimMethod -InputObject $service -MethodName StartService

# Change service startup type $service | Set-Service -StartupType Disabled

# Or: Set-Service -Name MyService -StartupType Automatic

# Force service to stop (WMI approach) ([wmiclass]"win32_service='$MyService'").StopService()

# Get service exit code $service.ExitCode

# Get specific error: $service | Select-Object Name, State, ExitCode, PathName

# Try changing service account: $service | Set-Service -Credential (Get-Credential)

# Check service description $service.Description

# Modify service properties: $service | Set-Service -Description "My Service Description"

# Use Change method to modify service: $service.Change($null, $null, $null, $null, $null, $null, "NewPassword", "DOMAIN\NewUser") ```

Step 8: Check for Pending Service Operations

Find and clear pending service operations.

```powershell # Check for service operations in pending state # Look at Session Manager settings:

reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations

# If found, clear them: reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager" /v PendingFileRenameOperations /f

# Check for Windows Update pending operations: reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" 2>nul

# Check for pending reboot: reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" 2>nul

# If pending reboot, reboot the server: shutdown /r /t 60 /c "Rebooting to clear stuck service"

# Check for pending XML operations: reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Services" /s

# Look for service installation in progress: Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Name PendingFileRenameOperations -ErrorAction SilentlyContinue ```

Step 9: Troubleshoot Service Dependencies

Fix dependency issues causing stuck state.

```powershell # List service dependencies: Get-Service MyService -RequiredServices | Format-Table Name, Status

# Check dependent services: Get-Service MyService -DependentServices | Format-Table Name, Status

# Stop dependent services first: Get-Service MyService -DependentServices | Stop-Service -Force

# Then try to stop the main service: Stop-Service MyService -Force

# Check services in dependency chain: $service = Get-Service MyService $dependencies = $service.RequiredServices

foreach ($dep in $dependencies) { Write-Host "$($dep.Name): $($dep.Status)" if ($dep.Status -match "Pending") { Write-Host "Dependency $($dep.Name) is stuck!" } }

# Try stopping in reverse dependency order: $dependentServices = Get-Service MyService -DependentServices foreach ($svc in $dependentServices) { try { Stop-Service $svc.Name -Force -ErrorAction Stop Write-Host "Stopped $($svc.Name)" } catch { Write-Host "Failed to stop $($svc.Name): $_" } }

# Clear service dependency (use with caution): sc config MyService depend= ""

# Re-add dependencies after fixing: sc config MyService depend= LanmanWorkstation/TCPIP ```

Step 10: Reinstall the Service

Remove and reinstall the problematic service.

```powershell # Export current service configuration first: sc qc MyService > C:\temp\MyService_config.txt

# Note the binary path: # BINARY_PATH_NAME : C:\Program Files\MyApp\MyService.exe

# Delete the service: sc delete MyService

# Wait a few seconds: Start-Sleep -Seconds 5

# Verify service is deleted: Get-Service MyService -ErrorAction SilentlyContinue

# If still listed, refresh services: # Reboot might be required

# Recreate the service: sc create MyService binPath= "C:\Program Files\MyApp\MyService.exe" start= auto DisplayName= "My Service Application"

# Set description: sc description MyService "My Service Application Description"

# Configure recovery options: sc failure MyService reset= 86400 actions= restart/5000/restart/5000/restart/5000

# Set service account if needed: sc config MyService obj= "DOMAIN\ServiceAccount" password= "Password"

# Start the service: sc start MyService

# Verify: sc query MyService

# If service installer exists: & "C:\Program Files\MyApp\InstallUtil.exe" /u MyService.exe & "C:\Program Files\MyApp\InstallUtil.exe" MyService.exe ```

Checklist for Fixing Stuck Windows Services

StepActionCommandStatus
1Identify stuck services`Get-Service \Where Status -like "*Pending"`
2Try normal commands with timeoutStop-Service -Force
3Kill the service processStop-Process -Id $PID -Force
4Force state via registryEdit HKLM\SYSTEM\CurrentControlSet\Services
5Use sc.exe commandssc stop MyService, sc control MyService 1
6Restart SCM (safe mode)bcdedit /set safeboot minimal
7Use PowerShell CIM methodsInvoke-CimMethod -MethodName StopService
8Check pending operationsQuery registry for pending operations
9Troubleshoot dependenciesCheck RequiredServices and DependentServices
10Reinstall the servicesc delete, sc create

Verify the Fix

After fixing stuck Windows service:

```powershell # 1. Service shows proper status Get-Service MyService # Status should be Running, Stopped, or one of the valid states

# 2. Service responds to commands Start-Service MyService Stop-Service MyService # Should complete without hanging

# 3. No services in pending state Get-Service | Where-Object { $_.Status -like "*Pending" } # Should return nothing

# 4. Service can be restarted Restart-Service MyService # Should complete successfully

# 5. Service process is running (if started) Get-Process -Name MyService -ErrorAction SilentlyContinue # Should return process info

# 6. No errors in event log Get-EventLog -LogName System -Source "Service Control Manager" -Newest 10 | Where-Object { $_.Message -like "*MyService*" } # No recent errors

# 7. Service configuration is correct sc qc MyService # Shows expected configuration

# 8. Dependencies work Get-Service MyService -RequiredServices # All required services are running

# 9. Recovery options set correctly sc qfailure MyService # Shows configured recovery actions

# 10. Service is accessible via all tools # Services.msc shows correct state # PowerShell commands work # sc.exe commands work ```

  • [Fix Windows Service Permission Denied](/articles/fix-windows-service-permission-denied) - Access denied errors
  • [Fix Windows Service Not Starting Automatically](/articles/fix-windows-service-not-starting) - Startup issues
  • [Fix Windows Service Account Locked](/articles/fix-windows-service-account-locked) - Account problems
  • [Fix Systemd Service Failed to Start](/articles/fix-systemd-service-failed-start-automatically) - Linux equivalent
  • [Fix Windows Disk Full Server](/articles/fix-windows-disk-full-server) - Disk space issues
  • [Fix Windows BSOD System Service Exception](/articles/fix-windows-bsod-system-service-exception) - Blue screen errors
  • [Fix Windows Backup Failed](/articles/fix-windows-backup-failed) - Backup service issues