Windows Services are programs that run in the background of the Windows operating system and provide important functions such as security, networking, printing, etc. Windows services can be started automatically when the system is turned on, or manually by the user or administrator. Windows services can also be stopped, paused, or resumed as needed.
One way to manage Windows services is to use Command Prompt or CMD. CMD is a built-in Windows tool that allows users to run text commands to perform various tasks. Using CMD, users can view a list of available Windows services, find out the status of the service, change the service’s startup mode, and control service operations such as starting, stopping, pausing, and resuming.
In this article, Bardimin will discuss how to manage Windows services using CMD with details and examples. This article will be divided into several parts, namely:
- How do I open CMD as an administrator
- How to view a list of available Windows services
- How to find out the status of Windows services
- How to change the startup mode of a Windows service
- How to control the operation of Windows services
How do I open CMD as an administrator
To manage Windows services using CMD, we need to open CMD as administrator. This is because some Windows services require high permissions to be changed or controlled. If we open CMD as a regular user, we might get error messages like “Access is denied” or “The requested pause, continue, or stop is not valid for this service”.
Here are the steps to open CMD as an administrator:
- Click the Start button in the lower-left corner of the screen
- Type cmd in the search box
- Right-click on the search result Command Prompt and select Run as administrator
- Click Yes on the User Account Control dialog box that appears
After that, we will see a CMD window with the title Administrator: Command Prompt. This signifies that we have successfully opened CMD as an administrator.
How to view a list of available Windows services
To see the list of Windows services available on our system, we can use the command sc query. This command will display information about all services registered in Windows, including the service name, display name, type, status, and others.
Here is an example output of the sc query command:
C:\Windows\system32>sc query SERVICE_NAME: AdobeARMservice DISPLAY_NAME: Adobe Acrobat Update Service TYPE : 10 WIN32_OWN_PROCESS STATE : 4 RUNNING (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 ...
From the output above, we can see that there is some information displayed for each service, namely:
- SERVICE_NAME: This is the internal service name used by the system. This name is unique and cannot be changed. This name is also used as a parameter for other commands related to service.
- DISPLAY_NAME: This is the name displayed for the service in the user interface, such as Services or Task Manager. This name can be changed by the user or administrator through the service property.
- TYPE: This is the type of service, which determines how the service is run by the system. There are several types of services, namely:
- WIN32_OWN_PROCESS: This service runs in its process, which means it doesn’t share resources with other services. This service can interact with the user’s desktop if allowed.
- WIN32_SHARE_PROCESS: This service is run in a process along with other services of the same type. This service cannot interact with the user’s desktop.
- KERNEL_DRIVER: This service is a kernel device driver, which is part of the core operating system. This service runs when the system is turned on and cannot be stopped or paused by the user or administrator.
- FILE_SYSTEM_DRIVER: This service is a file system driver, which manages access to the file system. This service runs when the system is turned on and cannot be stopped or paused by the user or administrator.
- STATE: This is the status of the service, which indicates the operational condition of the service. There are several service statuses, namely:
- STOPPED: This service is not running and doing nothing.
- START_PENDING: This service is in the process of starting, but not ready to accept requests yet.
- STOP_PENDING: This service is in the process of retiring, but has not completely stopped.
- RUNNING: This service is running and ready to accept requests.
- CONTINUE_PENDING: This service is in the process of resuming after being paused, but is not yet fully operational.
- PAUSE_PENDING: This service is in the process of pausing, but has not been completely paused.
- PAUSED: This service is paused and doesn’t accept new requests, but still retains its previous state and resources.
- WIN32_EXIT_CODE: This is the error code returned by the service when the service stops normally. If the service stops successfully, this code will be 0. If the service stops with an error, this code will indicate the type of error that occurred. This code can be searched on the internet to get further explanation.
- SERVICE_EXIT_CODE: This is the error code returned by the service when the service stops for a specific reason specified by the service itself. If the service does not specify a specific reason, this code will be 0. This code can be searched on the internet to get further explanation.
- CHECKPOINT: This is the value used by the system to monitor the progress of the service while the service is in the process of starting, stopping, pausing, or resuming. This value will increment periodically during the process and will reset to 0 when the process is complete. If this value does not change within the time specified by the WAIT_HINT, the system assumes that the service has failed.
- WAIT_HINT: This is the maximum time in milliseconds estimated by the service to complete the start, stop, pause, or resume process.
How to find out the status of Windows services
To find out the status of a particular Windows service, we can use the command sc query by adding the service name as a parameter. This command displays information about the service in question, including its status.
Here’s an example of how to find out the status of service Windows Update:
C:\Windows\system32>sc query wuauserv SERVICE_NAME: wuauserv DISPLAY_NAME: Windows Update TYPE : 20 WIN32_SHARE_PROCESS STATE : 4 RUNNING (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0
From the output above, we can see that the service Windows Update is running (RUNNING) and can be stopped, paused, or turned off (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN).
If we don’t know the exact name of the service, we can use the sc queryex command by adding the display name of the service as a parameter. This command will display the same information as the sc query command but also display the PID or Process ID of the service, which is the identification number of the process running the service.
Here’s an example of how to find out the status of service Windows Firewall:
C:\Windows\system32>sc queryex “Windows Firewall” SERVICE_NAME: MpsSvc DISPLAY_NAME: Windows Firewall TYPE : 20 WIN32_SHARE_PROCESS STATE : 4 RUNNING (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 PID : 1004 FLAGS :
From the output above, we can see that service Windows Firewall has the name of service MpsSvc and is running with PID 1004. This Service can also be stopped, paused, or turned off (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN).
Other Interesting Articles
How to change the startup mode of a Windows service
The Windows service startup mode is a setting that determines how the service is run when the system is turned on. There are several Windows service startup modes, namely:
- Automatic: This service will run automatically when the system is turned on, without the need for user or administrator intervention.
- Manual: This service will not be executed automatically when the system is turned on but can be run manually by the user or administrator through CMD or other user interfaces.
- Disabled: This service will not run at all, either automatically or manually. This service can only be reactivated by an administrator.
To change the startup mode of a Windows service, we can use the command sc config by adding the name of the service and the desired startup mode as parameters. This command will change the registry settings associated with that service.
Here’s an example of how to change the service startup mode from Windows Defender Antivirus Service to Manual:
C:\Windows\system32>sc config WinDefend start= demand [SC] ChangeServiceConfig SUCCESS
From the output above, we can see that the command successfully changed the startup mode of the WinDefend service to demand, which means Manual. Note that there is a space after the equal sign (=) in this command.
Here is a list of startup modes that can be used as parameters in the sc config command:
- boot: This service will run before the operating system loads. Only kernel and file system services can use this mode.
- system: This service will run when the operating system loads. Only kernel and file system services can use this mode.
- auto: This service will run automatically when the system is turned on. This is the same as Automatic mode.
- demand: This service will not run automatically when the system is turned on but can be run manually. This is the same as Manual mode.
- disabled: This service will not run at all. This is the same as the Disabled mode.
How to control the operation of Windows services
Windows service operations are actions that can be performed against a service, such as starting, stopping, pausing, or resuming. These operations can affect the state and functionality of the service.
To control the operation of Windows services, we can use the sc command by adding the name of the service and the desired operation as parameters. This command sends the request to the service and displays the results.
Here’s an example of how to start service Windows Audio:
C:\Windows\system32>sc start Audiosrv SERVICE_NAME: Audiosrv TYPE : 20 WIN32_SHARE_PROCESS STATE : 2 START_PENDING (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x7d0 PID : 1508 FLAGS :
From the output above, we can see that the command successfully sent a request to start the service Audiosrv and that the service is in the process of starting (START_PENDING).
Here is a list of operations that can be used as parameters in sc command:
- start: This service will start if the service has a status of STOPPED.
- stop: This service will be terminated if it has a status of RUNNING, PAUSED, START_PENDING, or CONTINUE_PENDING.
- pause: This service will be paused if the service is RUNNING or CONTINUE_PENDING.
- continue: This service will continue if the service is PAUSED or PAUSE_PENDING.
Conclusion
By using CMD, we can manage Windows services easily and quickly. We can view the list and status of services, change the startup mode of the service, and control the operation of the service using the commands we discussed above. Thus, we can improve the performance and security of our system according to our needs.