How to restart service using command prompt?
Categories:
How to Restart Services Using Command Prompt in Windows
Learn to efficiently manage and restart Windows services using the Command Prompt, a crucial skill for system administrators and power users.
Managing Windows services is a fundamental task for maintaining system health, troubleshooting applications, and ensuring smooth operation. While the Services management console provides a graphical interface, the Command Prompt offers a powerful, scriptable, and often faster way to interact with services. This article will guide you through the essential commands to start, stop, and restart services directly from the Command Prompt, providing you with a robust toolset for system administration.
Understanding Windows Services and Their States
Before diving into commands, it's important to understand what Windows services are and their various states. Services are programs that run in the background, performing specific functions without requiring user interaction. They can be set to start automatically when the system boots, manually, or be disabled entirely. Key service states include:
- Running: The service is currently active and operational.
- Stopped: The service is not running.
- Pausing/Paused: The service is temporarily suspended.
- Starting/Stopping: The service is in the process of changing its state.
Knowing the service name is crucial for command-line operations. You can find this in the 'Services' management console (services.msc) under the 'Name' column, or by using the sc query
command.
sc query | find "SERVICE_NAME"
Use sc query
to list all services and find
to filter by a keyword, helping locate the exact SERVICE_NAME
.
Basic Service Control Commands
The primary commands for service management via Command Prompt are net start
, net stop
, and sc
. While net
commands are simpler for basic start/stop operations, sc
(Service Control) offers more advanced functionalities and is generally preferred for scripting and comprehensive service management. For restarting a service, you'll typically combine net stop
and net start
or use sc stop
followed by sc start
.
Let's look at the basic operations.
1. Step 1
Step 1: Stop a Service
To stop a running service, use the net stop
command followed by the service name. For example, to stop the 'Print Spooler' service:
2. Step 2
Step 2: Start a Service
Once a service is stopped, you can start it using the net start
command. For example, to start the 'Print Spooler' service:
3. Step 3
Step 3: Restart a Service (Combined Operation)
There is no direct net restart
command. To restart, you must first stop the service and then start it. This sequence ensures a clean restart. For example, to restart the 'Print Spooler' service:
Tab 1
net stop "Spooler"
Tab 2
net start "Spooler"
Tab 3
net stop "Spooler"
net start "Spooler"
Advanced Service Control with sc
Command
The sc
command provides more granular control over services, including querying their status, configuring startup types, and deleting services. It's particularly useful for scripting and automation.
1. Step 1
Step 1: Stop a Service with sc
The sc stop
command is similar to net stop
. For example, to stop the 'Print Spooler' service:
2. Step 2
Step 2: Start a Service with sc
To start a service using sc
:
3. Step 3
Step 3: Query Service Status with sc
To check the current status of a service:
4. Step 4
Step 4: Restart a Service with sc
(Combined Operation)
Similar to net
commands, a restart with sc
involves stopping and then starting the service.
Tab 1
sc stop Spooler
Tab 2
sc start Spooler
Tab 3
sc query Spooler
Tab 4
sc stop Spooler
sc start Spooler
Workflow for restarting a Windows service using Command Prompt.
Using the Command Prompt to manage services offers flexibility and efficiency, especially when dealing with remote machines or automating tasks. By mastering these commands, you gain a powerful tool for maintaining robust and responsive Windows systems.