Built a Windows service? Great. Now you need it running automatically in the background—even when no one's logged in. Without proper installation, your executable will just sit there. The best way to handle this? Use sc.exe or PowerShell. These register your program with Windows so it behaves like a real service.
Quick Fix Summary:
Fire up Command Prompt as Administrator and type:
sc create "MyService" binPath= "C:\path\to\your\service.exe" start= auto
Then wake it up:
sc start "MyService"
What's Happening
A Windows service runs invisibly in the background. It doesn't need a window or user interaction. But to become a real service, your program must register with the Service Control Manager (SCM). The SCM tracks every service's status, dependencies, and startup behavior. Run your EXE directly? It won't survive reboots or logouts—that's not how services work.
As of 2026, sc.exe and PowerShell remain the standard tools for service installation. The old InstallUtil.exe method? Mostly obsolete now. It can cause security headaches and compatibility issues. Services installed that way often break after Windows updates or fail to integrate with modern security models.
Step-by-Step Solution
Open Command Prompt as Administrator
- Hit Win + X and pick Terminal (Admin) or Command Prompt (Admin).
- Or search for "cmd", right-click, and choose Run as administrator.
Create the service using sc.exe
Run this command, swapping in your actual path:
sc create "MyService" binPath= "C:\MyApp\MyService.exe" start= autoPro tip: There's a space after
binPath=but none after the equals sign instart= auto. Thestart= autoflag makes it boot with Windows. Want manual control instead? Usestart= demand.Start the service immediately
sc start "MyService"If it balks, check the Windows Event Log for clues (we'll cover troubleshooting next).
Manage the service
Use these commands to control your new service:
sc stop "MyService"– Hit the brakessc query "MyService"– Check its pulsesc delete "MyService"– Rip it out completely
If This Didn't Work
Service won't start? Let's fix that.
- Check the Event Viewer
Open Event Viewer (Win + X → Event Viewer), then navigate to Windows Logs > Application. Look for errors from the Service Control Manager or your service name. Common culprits? Missing dependencies, wrong permissions, or busted paths.
Microsoft Support notes that service failures usually include error codes—plug them into the Microsoft Error Lookup Tool to decode what went wrong.
- Verify the executable path
Double-check that path in
binPath=. It must be absolute—no..\bin\service.exeshortcuts. If your service runs under a specific account, that account needs access to the folder and files. Relative paths often break when Windows starts up. - Use PowerShell for more control
PowerShell gives you cleaner error messages and more options. Run it as Administrator and try:
New-Service -Name "MyService" -BinaryPathName "C:\MyApp\MyService.exe" -StartupType AutomaticTo wake it up:
Start-Service -Name "MyService"PowerShell also lets you set a friendly
DisplayNameandDescriptionso it looks better in the Services console.
Prevention Tips
Don't wait for crashes to learn these lessons.
- Use a service wrapper
Tools like NSSM (Non-Sucking Service Manager) handle the heavy lifting. They manage recovery options, logging, and user context far better than raw
sc.execommands. Install once, then use:nssm install MyService "C:\path\to\service.exe"NSSM doesn't just create a service entry—it lets you configure recovery actions (like restarting after a crash), which
sc.execan't do. - Test service behavior before deployment
Use DebugView from Microsoft's Sysinternals suite to see console output from your service—even when it's running as a service. Catches startup errors early.
Grab it from the Microsoft Sysinternals page.
- Set proper recovery options
In Services.msc, right-click your service, choose Properties → Recovery. Configure what happens on first, second, and subsequent failures (restart the service, run a script, etc.). This keeps your app alive even if it crashes silently.
Microsoft recommends recovery actions for long-running services in their documentation.