Run with restricted Rights
Free!

Easily Start, Stop or Restart any Windows Service

Our free alternative to NET and SC reliably starts/stops/restarts long-running Windows Services from your batch files and scripts


(Restarting the Print Spooler service - click to enlarge)

How to Use ServicePilot: The Command-line Interface


ServicePilot.exe <-start|-stop|-restart> [-wait ] [-noforce]
                 [-computer ] [-args ] [-verbose] <service-name>

where:

    -start           Start the service.
    -stop            Stop the service.
    -restart         Restart the service.
    -wait <sec>      Wait for at least <sec> seconds before giving up or
                     taking action. When stopping a service and it does not
                     transition to the Stopped state in <sec> seconds, the
                     service's process will be forcibly terminated (unless the
                     -noforce option has been specified). When starting and
                     the service does not transition to the Running state in
                     <sec> seconds, the operation will fail.
                     If not provided, the default value is 120 seconds.
    -noforce         When stopping the service, do not try to forcibly terminate
                     the service's process if all else fails.
    -computer <name> Instead of working with the local computer, work with the
                     service on the computer with name (or IP address) <name>.
    -args <params>   Pass the given set of parameters when starting the service.
                     Separate each parameter with a space. Be sure to quote the
                     entire set of parameters!
    -verbose         Produce verbose output.
    <service-name>   The name (or display name) of the service. Please be
                     sure to enclose the name in quotes if it contains at least
                     one space. Note: using the service name is more efficient.

Upon completion, the exit code is 0 if the operation completed successfully and 1 if it did not. You can access that exit code via the standard ERRORLEVEL variable.


Using ServicePilot: Three Real-World Examples

  1. Restarting the Apple Mobile Device Service

    If an iPhone, iPad, or iPod touch isn't recognized in iTunes on Windows, the Apple Mobile Device Service may need to be restarted. The telltale sign is this error message when connecting your device: "This [device] cannot be used because the Apple Mobile Device Service is not started".

    To restart the service, issue this command:

    ServicePilot.exe -restart "Apple Mobile Device Service"
  2. Stopping a "slow" (or busy) service

    If your service takes a long time to stop (or gets stuck stopping), you should set a long enough "wait time" when using ServicePilot.

    For example, we know that our "Device Automation" service can take up to two minutes to shut down. We use this command to stop it:

    ServicePilot.exe -stop -wait 120 "Device Automation"

    Running with the verbose parameter shows how long it takes to stop the service:

    This has been an improvement over NET STOP, which would routinely throw up its hands after a timeout!

  3. Starting a service with parameters

    Some services accept parameters when started. Those parameters can be specified in the Service Control panel application:

    Service Pilot allows you to provide parameters from the command line. This command starts our "RetailConnection" service with the port number it should use (8080), in debug mode:

    ServicePilot.exe -start -args "/port 8080 /debug" RetailConnection


Start/stop/restart any Windows Service

Why use ServicePilot instead of NET?

NET.EXE will happily start or stop a service but it falls short of ServicePilot in a couple of areas:

  1. NET will wait at most 30 seconds for your service to start or stop. This can be a problem for services that take a while to transition.

    The inability for NET to patiently wait can lead to unexpected errors in a batch files. For example, suppose a script contains a NET STOP followed by a NET START. If the service takes longer than 30 seconds to shut down, then NET STOP will fail and the subsequent NET START will fail as well. The end result is that the service will likely end up stopped and out of commission — the very situation that the script was trying to avoid!

  2. It can be awkward to pass parameters to the service using NET START. Each item must be separated out and prefixed with a slash ("/").

    For example, this command starts the Spooler service with parameters "one" "two" and "three":

    NET START Spooler /"one" /"two" /"three"

    It is cumbersome to write the batch file commands to pull apart an existing command line and compose those unnatural prefixed values. ServicePilot's syntax is much less demanding:

    ServicePilot -start "one two three" Spooler


Start/stop/restart any Windows Service

Why use ServicePilot instead of SC?

SC.EXE will also handle starting and stopping a service, but it has some shortcomings as well:

  1. Unlike NET START, SC START simply issues the command to start a service and promptly ends. SC does not attempt to wait for the service to transition to the Running state.

    Because of this, a script using SC to restart a service must be contain extra complexity. After SC START, the script must loop, periodically checking for the status of the service and breaking out of the loop when the service moves to the Running state.

    ServicePilot will fully restart a service, without extra fuss.

  2. SC STOP ask politely for the service to stop, but it will not terminate the underlying process if the service fails to stop in a timely manner. SC cannot stop "rogue" services, which don't respond to the Services Control Manager (SCM).

    By default, ServicePilot will try to stop the service's process if the service doesn't transition to the Stopped state within a given timeout period. This behavior can be turned off by specifying the "-noforce" parameter.


Start/stop/restart any Windows Service

What else would you like ServicePilot to do?

We are constantly improving sour software. Please get in touch and let us know how we can do better!


Download

Download ServicePilot Version 1.0 New!

280 KB EXE
  • Ready-to-run - no installation
  • For Windows 10/8.1/8/7 and Windows Server 2016/2012 R2/2008

Our customers include...