Home
» PC Tips
»
How to manage Windows services via command line
How to manage Windows services via command line
People are always looking for efficient ways to manage system tasks without leaving the terminal, even when using Windows. On Windows, services run in the background to keep the system and applications running smoothly. Instead of opening the Services Manager, many people prefer to manage Windows services through the command line. In today’s tutorial, we will explore these methods and see how you can manage Windows services right from the terminal.
sc.exe is a built-in command-line tool for managing Windows services. It allows you to configure, query, and control services directly from the terminal. With sc.exe, you can have complete control over Windows services without the need for the graphical Services Manager.
Check service status with sc
We can use the sc query serviceName command to check the status of a specific service. For example, we run the sc query MySQL80 command to retrieve detailed information about the MySQL80 service, including its status:
Check service status with sc
MySQL is not running on the machine at the moment.
Start a service with sc
To start a specific service using sc.exe, we can use the sc start ServiceName command . For example, we run sc start MySQL80 to start the MySQL80 service. To verify whether the service has started successfully, we can check the status of the service using the sc query MySQL80 command :
Stop a service with sc
You can stop a service to free up system resources. For example, the sc stop MySQL80 command stops MySQL, which can be verified with the sc query MySQL80 command :
Create a new service using sc
We can create a new service using the sc create command . This command requires specifying the service name, executable path, and startup type. For example, to create a new service called "mte" that will start automatically on boot, type:
sc create mte binPath= "C:\Users\HP\Desktop\Examples\Service.exe" start= auto
Update a service using sc
We can use the sc config command to configure an existing service. For example, to change the startup type to manual, run the command:
sc config serviceName start= demand
Delete service using sc
When the service is no longer needed, we can permanently remove it from Windows with the command:
sc delete srviceName
2. Manage Windows services using the Net command
The net command in Windows allows us to manage services from the command line. This command allows users to start, stop, pause, resume, and query services without using the graphical Services Manager.
Start and stop services using the net command
We can start or stop Windows services using the net start serviceName and net stop serviceName commands respectively:
Start or stop service with net command
Pause and resume service using net command
Some Windows services support pausing and continuing instead of stopping completely. In that case, we can use the net pause ServiceName and net continue ServiceName commands respectively:
Pause and resume net service
Check service status with net command
The net command itself does not provide a direct way to check the status of a specific service, but we can use it in conjunction with the findstr command to filter the results. For example, to check if a specified service is running, type:
net start | findstr "ServiceName"
Check service status with net command
If the specified service is running, the command returns the name of that service; otherwise, there is no output.
Manage remote services using the net command
We can use the net command to manage services on a remote computer by specifying the computer name. For example, the net start ServiceName /S RemotePC and net stop ServiceName /S RemotePC commands are used to start or stop services on a remote computer.