• Thread Author

Manage Windows Services: Create, Configure & Set Recovery Options (Win10/11)​

Difficulty: Intermediate | Time Required: 20 minutes

Introduction​

Windows Services run in the background and are used for everything from networking to third‑party utilities. Knowing how to create, configure and set recovery options for services helps you automate tasks, improve reliability, and troubleshoot issues quickly. This guide covers both GUI and command‑line methods (PowerShell and sc.exe) for Windows 10 and Windows 11 so you can pick the approach that suits you.

Prerequisites​

  • Administrator privileges (UAC elevation required).
  • The service binary must be a true Windows Service (an executable that implements the Windows Service API). Simply pointing to a normal desktop app will not work as expected.
  • Basic familiarity with PowerShell or Command Prompt is helpful.
  • Tested on Windows 10 (1809+) and Windows 11 (all current builds).

Step-by-step instructions​

1) Open an elevated session
  1. Press Start, type PowerShell or cmd.
  2. Right‑click and choose “Run as administrator”.
  3. Approve the UAC prompt.
2) Create a new service (PowerShell method)
  1. Prepare the path to your service executable, e.g. C:\Services\MyService.exe.
  2. Run:
    • New-Service -Name "MyService" -BinaryPathName "C:\Services\MyService.exe" -DisplayName "My Background Service" -StartupType Automatic
  3. Verify creation:
    • Get-Service -Name "MyService"
    Note: New‑Service sets basic properties (name, binary, startup type). To set a custom account or description use New‑Service parameters or set those later via services.msc.
3) Create a service (sc.exe method)
  1. In elevated Command Prompt:
    • sc create MyService binPath= "C:\Services\MyService.exe" DisplayName= "My Background Service" start= auto
  2. Important: sc’s syntax requires a space after the equals sign (binPath= "..." not binPath="...").
  3. Confirm:
    • sc qc MyService
    • sc query MyService
4) Configure service startup type, description, and logon
  • GUI: Press Win+R → services.msc → locate the service → right‑click → Properties.
    • General tab: change Startup type (Automatic / Manual / Disabled).
    • Log On tab: change the account (Local System, Network Service, or a specific user). If you use a domain/service account, ensure “Log on as a service” rights are assigned.
    • Recovery tab: see next step to set failure actions.
  • PowerShell:
    • Set-Service -Name "MyService" -StartupType Manual
    • (For description) use: Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\MyService" -Name "Description" -Value "My Background Service"
  • sc:
    • sc config MyService start= demand
5) Set recovery options (GUI method — easiest)
  1. services.msc → right‑click your service → Properties → Recovery tab.
  2. Configure First failure, Second failure, Subsequent failures (e.g. Restart the Service).
  3. Optionally enter a program/script to run on failure, or set a restart delay.
  4. Click OK to save.
6) Set recovery options (sc.exe / automation method)
  1. Example: set the service to restart immediately on first two failures and run a command on the third failure:
    • sc failure "MyService" reset= 86400 actions= restart/5000/restart/5000/run/60000 command= "C:\Scripts\OnServiceFail.bat"
  2. Notes about sc failure:
    • There must be a space after each equal sign (reset= 86400).
    • actions= expects a slash-delimited list of action/delay pairs. Delays are in milliseconds (e.g. restart/5000 = restart after 5 seconds).
    • command= sets a program to run when an action is "run".
  3. Verify with:
    • sc qfailure "MyService"
7) Test your settings
  1. Start the service: Start-Service -Name "MyService" or via services.msc.
  2. Stop it or simulate a failure (if safe) to confirm recovery behavior.
  3. Check Event Viewer (Windows Logs → System) for entries related to service start/stop and recovery actions.

Tips and troubleshooting notes​

  • Tip: Use meaningful DisplayName and Description values so services.msc and Event Viewer entries are easy to read.
  • Tip: When using a custom account, grant it the “Log on as a service” right via Local Security Policy (secpol.msc → Local Policies → User Rights Assignment) or use Group Policy for domain accounts.
  • Warning: Don’t point a service to a GUI app or a console app that doesn’t implement the Service Control Handler. It may appear to start but will fail to respond to Service Control Manager commands.
  • Note on sc syntax: The sc.exe command is picky about spacing (space after =). If commands fail inexplicably, re-check spacing and quoting.
  • Troubleshooting:
    • If the service won’t start, run sc queryex MyService and check error codes. Use Event Viewer for detailed errors.
    • If you need to remove a service: sc delete MyService (run elevated).
    • Use Process Monitor or Sysinternals tools if the service fails silently during initialization.
  • Windows 10/11 differences: GUI and command-line behavior is the same across modern releases; differences are only relevant if using older or heavily locked-down environments (e.g., Windows 10 LTSC or very old Win10 builds). PowerShell cmdlets shown are available in Windows Management Framework included in modern Win10/11 builds.

Security considerations​

  • Limit service logon privileges — use the least-privileged account that still allows access to required resources.
  • Protect service binary and any scripts used by recovery actions so attackers cannot modify them.
  • If your recovery action runs a script, ensure script execution policies and file permissions are set securely.

Conclusion​

Managing Windows Services properly gives you control over background processes, improved application resilience, and better automation. Whether you prefer the services.msc GUI for quick tweaks or PowerShell/sc.exe for automation, you can create, configure and set robust recovery behaviors that keep your systems running smoothly.
Key Takeaways:
  • Use elevated PowerShell (New-Service/Set-Service) or sc.exe to create and automate services.
  • services.msc offers an easy GUI for changing startup type, logon account, and recovery options.
  • Configure recovery actions (restart, run a program) to improve service reliability.
  • Always run commands as Administrator, verify syntax (sc’s spacing), and ensure service binaries implement the Windows Service API.
  • Secure service accounts and binaries to reduce attack surface.

This tutorial was generated to help WindowsForum.com users get the most out of their Windows experience.