What's Actually Happening

Windows service fails to start when attempting to manually start it or after system reboot. Service remains in stopped state.

The Error You'll See

```powershell $ Start-Service -Name "MyService"

Start-Service : Service 'MyService' cannot be started due to the following error: Cannot start service MyService on computer '.'. ```

Services MMC error:

bash
Windows could not start the MyService service on Local Computer.
Error 1053: The service did not respond to the start or control request in a timely fashion.

Event Log error:

bash
Event ID: 7000
The MyService service failed to start due to the following error:
The service did not respond to the start or control request in a timely fashion.

Why This Happens

  1. 1.Service dependencies not met - Required services not running
  2. 2.Service account locked/disabled - Logon account has issues
  3. 3.Service timeout - Service taking too long to start
  4. 4.Corrupted service binary - Service executable damaged
  5. 5.Missing dependencies - DLLs or components missing
  6. 6.Permission denied - Service lacks required permissions

Step 1: Check Service Status

```powershell # Check service status: Get-Service -Name "MyService"

# Detailed service info: Get-WmiObject Win32_Service -Filter "Name='MyService'"

# Check service configuration: sc qc MyService

# Check all services: Get-Service | Where-Object {$_.Status -eq "Stopped"}

# Check failed services: Get-WinEvent -LogName System | Where-Object {$_.Id -eq 7000} ```

Step 2: Check Service Dependencies

```powershell # List service dependencies: sc qc MyService

# Output shows: # DEPENDENCIES : Tcpip # Afd

# Check if dependencies are running: Get-Service -Name "Tcpip","Afd"

# Start dependencies first: Start-Service -Name "Tcpip" Start-Service -Name "Afd"

# Then start service: Start-Service -Name "MyService"

# Check dependent services (services that depend on this one): Get-Service | Where-Object {$_.DependentServices -ne $null} | Select-Object Name,DependentServices ```

Step 3: Check Service Account

```powershell # Check service account: sc qc MyService | findstr SERVICE_START_NAME

# Common accounts: # LocalSystem - Built-in system account # NT AUTHORITY\NetworkService - Network service account # NT AUTHORITY\LocalService - Local service account # Domain\User - Specific user account

# Check if account exists: net user MyServiceUser

# Check if account disabled: net user MyServiceUser | findstr "Account active"

# Enable account: net user MyServiceUser /active:yes

# Check account password: # If using domain account, verify password not expired net user MyServiceUser /domain

# Change service account: sc config MyService obj= "NT AUTHORITY\NetworkService"

# Or with password: sc config MyService obj= "MyUser" password= "MyPassword" ```

Step 4: Check Event Logs

```powershell # Check System log for service errors: Get-WinEvent -LogName System -MaxEvents 50 | Where-Object {$_.ProviderName -eq "Service Control Manager"}

# Check Application log: Get-WinEvent -LogName Application -MaxEvents 50 | Where-Object {$_.Message -like "*MyService*"}

# Filter by Event ID: Get-WinEvent -LogName System | Where-Object {$_.Id -eq 7000 -or $_.Id -eq 7001 -or $_.Id -eq 7009}

# Common Event IDs: # 7000 - Service failed to start # 7001 - Service depends on service that failed # 7009 - Service start timeout # 7023 - Service exited with specific error # 7024 - Service installed improperly # 7031 - Service crashed # 7034 - Service crashed unexpectedly

# Export events: Get-WinEvent -LogName System | Where-Object {$_.Id -eq 7000} | Export-Csv service_errors.csv ```

Step 5: Check Service Timeout

```powershell # Default service timeout is 30 seconds # Check timeout setting: Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control" -Name ServicesPipeTimeout

# Increase timeout: Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control" -Name ServicesPipeTimeout -Value 60000

# Or in registry: reg add "HKLM\SYSTEM\CurrentControlSet\Control" /v ServicesPipeTimeout /t REG_DWORD /d 60000

# Restart service: Start-Service -Name "MyService"

# For specific service timeout in config: # Some services have their own timeout settings in registry: Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\MyService" -Name FailureActions ```

Step 6: Check Service Binary

```powershell # Find service executable path: sc qc MyService | findstr BINARY_PATH_NAME

# Check if file exists: Test-Path "C:\Program Files\MyApp\service.exe"

# Check file details: Get-Item "C:\Program Files\MyApp\service.exe"

# Check file hash (verify not corrupted): Get-FileHash "C:\Program Files\MyApp\service.exe" -Algorithm SHA256

# Check DLL dependencies: # Use Dependencies Walker or: dumpbin /dependents "C:\Program Files\MyApp\service.exe"

# Check if process can start manually: Start-Process "C:\Program Files\MyApp\service.exe"

# Check working directory: sc qc MyService | findstr WORKING_DIRECTORY ```

Step 7: Check Permissions

```powershell # Check service permissions: sc sdshow MyService

# Output format: SDDL string # D:(A;;CC;;;AU)(A;;CCLCRPRC;;;SU)...

# Grant permission to start service: sc sdset MyService "D:(A;;CCLCRPRC;;;BU)(A;;CC;;;AU)(A;;CCLCRPRC;;;SU)"

# Check folder permissions: Get-Acl "C:\Program Files\MyApp"

# Grant folder permissions: icacls "C:\Program Files\MyApp" /grant "MyServiceUser:(OI)(CI)F"

# Check registry permissions: Get-Acl "HKLM:\SYSTEM\CurrentControlSet\Services\MyService"

# Run service as admin for testing: # Change to LocalSystem temporarily: sc config MyService obj= LocalSystem Start-Service -Name "MyService" ```

Step 8: Reinstall Service

```powershell # Stop service first: Stop-Service -Name "MyService" -Force

# Delete service: sc delete MyService

# Or: Remove-Service -Name "MyService"

# Reinstall service: # Using service installer: "C:\Program Files\MyApp\install_service.exe"

# Or create service: sc create MyService binPath= "C:\Program Files\MyApp\service.exe" start= auto

# Set display name: sc config MyService DisplayName= "My Application Service"

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

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

# Start service: Start-Service -Name "MyService" ```

Step 9: Check Service Recovery Options

```powershell # Check recovery configuration: sc query MyService | findstr RECOVERY

# Set recovery actions: sc failure MyService reset= 86400 actions= restart/5000/restart/5000/none/5000

# Actions: # restart - Restart the service # reboot - Reboot the computer # run - Run a command # none - Take no action

# Set recovery command: sc failure MyService actions= run/5000 command= "C:\scripts\restart_service.bat"

# Check failure count: sc qfailure MyService

# Reset failure count: sc resetfailcount MyService

# Enable auto-restart in services.msc: # Right-click service -> Properties -> Recovery tab # First failure: Restart the Service # Second failure: Restart the Service # Subsequent failures: Run a program ```

Step 10: Debug Service Startup

```powershell # Enable service debug logging: # In service config: sc config MyService type= own type= interact

# Check if service can start in debug mode: # Some services have -debug flag: Start-Process "C:\Program Files\MyApp\service.exe" -ArgumentList "-debug"

# Check service parameters: sc qc MyService | findstr START_TYPE

# Change start type: sc config MyService start= demand # Manual sc config MyService start= auto # Automatic sc config MyService start= disabled

# Run as console app for testing: # Modify service to run as console temporarily

# Create debug script: cat << 'EOF' > debug_service.ps1 Write-Host "=== Service Status ===" Get-Service MyService | Format-List *

Write-Host "" Write-Host "=== Service Config ===" sc qc MyService

Write-Host "" Write-Host "=== Dependencies ===" Get-Service MyService | Select-Object -ExpandProperty ServicesDependedOn

Write-Host "" Write-Host "=== Recent Errors ===" Get-WinEvent -LogName System -MaxEvents 10 | Where-Object {$_.Id -ge 7000 -and $_.Id -le 7034}

Write-Host "" Write-Host "=== Service Account ===" Get-WmiObject Win32_Service -Filter "Name='MyService'" | Select-Object StartName

Write-Host "" Write-Host "=== Binary Path ===" Get-WmiObject Win32_Service -Filter "Name='MyService'" | Select-Object PathName EOF

.\debug_service.ps1 ```

Windows Service Checklist

CheckCommandExpected
Service existsGet-ServiceService listed
Dependenciessc qcDependencies running
Accountsc qcAccount valid
Binary pathsc qcPath exists
PermissionsGet-AclProper access
Event logsGet-WinEventNo errors
TimeoutRegistryAppropriate value

Verify the Fix

```powershell # After fixing service

# 1. Check service status Get-Service MyService // Status: Running

# 2. Start service Start-Service MyService // No errors

# 3. Check event log Get-WinEvent -LogName System -MaxEvents 10 // No service errors

# 4. Check dependencies Get-Service MyService | Select-Object -ExpandProperty ServicesDependedOn // All running

# 5. Test functionality # Run application that uses service // Service responds correctly

# 6. Check after reboot Restart-Computer Get-Service MyService // Service started automatically ```

  • [Fix Windows Service Crashing](/articles/fix-windows-service-crashing)
  • [Fix Windows Service Permission Denied](/articles/fix-windows-service-permission-denied)
  • [Fix Windows Service Timeout](/articles/fix-windows-service-timeout)