You can restart a service using the Command Prompt on Windows by using the net stop
and net start
commands or the sc
command. Below are the steps and details for restarting a service.
Method 1: Using net
Command
- Open Command Prompt with Admin Privileges
- Press
Win + S
, type “Command Prompt,” and select Run as administrator.
- Press
- Stop the Service Use the following command to stop the service:
net stop <service_name>
Replace
<service_name>
with the actual name of the service. - Start the Service After stopping the service, start it again using:
net start <service_name>
- Example To restart the Windows Update service:
net stop wuauserv net start wuauserv
Method 2: Using sc
Command
The sc
(Service Control) command offers more control over Windows services.
- Restart Service with
sc
You can directly restart a service using:sc stop <service_name> && sc start <service_name>
- Example To restart the Print Spooler service:
sc stop Spooler && sc start Spooler
- Query the Service Status Before restarting, you can check the current status of the service:
sc query <service_name>
Finding the Service Name
To find the correct service name:
- Press
Win + R
, typeservices.msc
, and press Enter. - Locate the desired service in the list.
- Right-click on it, select Properties, and note the Service Name (not the display name).
Automating the Restart Process
You can create a batch file to automate restarting a service:
- Open Notepad and enter:
net stop <service_name> net start <service_name>
- Save the file as
restart_service.bat
. - Run the batch file as an administrator.
Important Notes
- Always ensure you have the correct service name, as stopping critical services might impact system stability.
- For critical services, consider restarting the service during a maintenance window.