Install Windows Service From Command Line

2 min read

How to Install a Windows Service from the Command Line

Installing a Windows service from the command line is one of the most practical skills for developers, system administrators, and anyone who automates deployments. exe**, PowerShell, and **InstallUtil.Instead of clicking through a graphical installer, you can register, start, configure, and remove services using built-in tools such as sc.exe — all of which work in scripts, CI/CD pipelines, and remote sessions. This guide walks through every method step by step, explains the syntax quirks that trip people up, and shows you how to troubleshoot the most common errors.

What Is a Windows Service?

A Windows service is a long-running executable that operates in its own session, managed by the Service Control Manager (SCM). Services can start automatically at boot, run without a logged-in user, and restart themselves after a failure. Examples include SQL Server, Windows Update, and print spoolers.

Because services run in the background, they must implement a specific

Because services run in the background, they must implement a specific set of characteristics that the operating system expects—namely, a valid service type, a non‑empty displayName, and at least one attribute such as Description or StartupPath. These requirements are enforced by the Service Control Manager (SCM) before a service is even registered, so attempting to create a service without them often results in the error “Invalid service definition” or a cryptic exit code 1 Which is the point..

Not obvious, but once you see it — you'll see it everywhere Most people skip this — try not to..

Defining the Core Fields

When you define a new service, the most critical pieces are:

Field Typical Value How It’s Specified
DisplayName Human‑readable label shown in Services.msc -DisplayName or --DisplayName=
Description One‑line summary of purpose -Description= or --Description=
StartMode (or StartupType) Automatic, Manual, Disabled, or “Run level 0+ only” --start= auto, --start= manual, …
StartArguments Arguments passed to the executable at launch --start= arg1 arg2

Take this: the following command creates a service called “MyBackup” that starts automatically at boot, has no custom start arguments, and displays “Performs nightly backups”.

sc create MyBackup --desc "Runs nightly backup scripts" --start= auto

In PowerShell the same operation looks like:

New-Service -Name "MyBackup" -Description "Runs nightly backup scripts" -StartupType Automatic

Both tools enforce the presence of at least one of DisplayName, Description, or StartupType; omitting all of them will abort the creation attempt.


Step‑by‑Step Installation Options

1. Using the Classic sc.exe

  • Create:
    sc create "MyService" "My service does X" START= automatic
    
  • Start now:
    sc start MyService
    
  • Stop immediately:
    sc stop MyService
    
  • Restart:
    sc restart MyService
    
  • Check status:
    sc query MyService
    

**

Still Here?

Out the Door

You Might Find Useful

More Reads You'll Like

Thank you for reading about Install Windows Service From Command Line. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home