Service Management With Windows Sc From Command Line

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/service-management-windows-sc-command-line/
PINTEREST
PINTEREST
INSTAGRAM

Operating systems run services to server operating system or user level features. These windows services generally starts in the startup and stopped at the shutdown. But some time we need to start service after the start or a configuration change.

Windows provides different tools to manage services. We have all ready looked the native Powershell service management tools following tutorial.

Service Management With Windows Powershell From Command Line

Help

Detailed help about sc command can be get with /? option like below.

Help

Help

Syntax

sc command syntax is similar to the most of the windows command. First we specify server names if we want to run service command remote systems and then provide real command to operate on service. After those we specify service name and other options.

Naming Service

There are two identifier to name services. SERVICE_NAME is real name where we use for related service operations and will be used for identifier. DISPLAY_NAME is like a tag and used to provide more readable and understandable service names. In the following example we should use Appinfo for service operations.

Start Service

Services should be started in order serve. There are a lot of services in a windows operating systems. We will use start command in order to start windows service. Some services can be depended other services. In this situations we should start first dependency services.

LEARN MORE  How To Install,Start, Stop, Restart OpenSSH In Ubuntu, Debian, Kali, Mint?

In this example we will start the service named ProtectedStorage .

If the service starts without a problem it will print the status of the service. The STATE line shows the service is pending for start.

Stop Service

Stopping a windows service is very similar to starting it. We will just change the start command with stop command. In this example we will stop the service named ProtectedStorage where we have started it in previous step.

Stop Service

Stop Service

Display Detailed Service Status

Detailed information about a service can be displayed with query command by providing the service name. In this example we display information about ProtectedStorage service.

Display Detailed Service Status

Display Detailed Service Status

This command output will provide following information about the service.

  • SERVICE_NAME
  • TYPE line shows service type
  • STATE line shows current status of service like STOPPED , RUNNING , etc.
  • WIN32_EXIT_CODE line shows last stop event exit code
  • SERVICE_EXIT_CODE
  • CHECKPOINT
  • WAIT_HINT

List All Services

There is a lot of service in a default Windows installation. After the installation 3 party applications may add new services too. All of these services can be listed with query command and state=all options like below.

List All Services

List All Services

List Only Running Services

Previous example lists  all services those running or stopped. We may interested with only running services. If we provide no option to the  query command it will only print running services by default.

LEARN MORE  Linux Systemctl Tutorial

Restart Service

Services have configurations and these configurations can be changed during they are running. Or some services may start work incorrectly. In this situations restart services is the best way to make it work and apply new service configuration.

Pause Service

A service can be paused without loosing its session related information and data. And then this service can be resumed too. In order to pause a service the service should support pausing. In this example  we will pause ProtectedStorage service.

Resume or Continue Service

We will resume and continue an all ready paused service with continue command like below.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/service-management-windows-sc-command-line/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)