- Start or stop Windows service from command line (CMD)
- Reboot Windows computer from command line (CMD)
- Command to reboot windows computer
- To shutdown a Windows computer
- To abort computer reboot
- To force reboot by closing applications without warning
- Add reason for the reboot of the computer
- Reboot windows using WMIC
- How do I shutdown, restart, or log off Windows via a bat file?
- 10 Answers 10
- How to restart Microsoft Windows
- Restarting from the Windows desktop
- Restarting through the Start menu
- Windows 10
- Windows 8 and 8.1
- Windows Vista and 7
- Windows XP and prior versions
- Using Ctrl+Alt+Delete to restart
- Windows 10
- Windows 8
- Windows Vista and 7
- Windows XP and prior
- Using the Windows command line
- How to reboot from an error message
- Physical restart with button on computer
- The Core Technologies Blog
- Our Software // Windows Services // 24×7 Operation
- Essential Tools for Windows Services: The NET Command
- Using NET to stop a Windows Service
- Starting a Windows Service with NET
- How to Restart a Windows Service with NET.EXE
- NET will also Pause and Resume Windows Services
- You may also like.
- 28 Responses to Essential Tools for Windows Services: The NET Command
Start or stop Windows service from command line (CMD)
We normally use Services.msc to start or stop or disable or enable any service. We can do the same from windows command line also using net and sc utilities. Below are commands for controlling the operation of a service.
Command to stop a service:
To start a service:
You need to have administrator privileges to run net start/stop commands. If you are just a normal user on the computer, you would get an error like below.
To disable a service:
To enable a service:
To make a service start automatically with system boot:
Note: Space is mandatory after ‘=’ in the above sc commands.
This SC command works on a Windows 7 machine and also on the down-level editions of Windows i.e Windows XP/2003 and Windows Vista. Again, if you do not have administrator previliges you would get the below error.
Note that the service name is not the display name of a service. Each service is given a unique identification name which can be used with net or sc commands. For example, Remote procedure call (RPC) is the display name of the service. But the service name we need to use in the above commands is RpcSs.
So to start Remote procedure call service the command is:
These service names are listed below for each service. The first column shows the display name of a service and the second column shows the service name that should be used in net start or net stop or sc config commands.
Reboot Windows computer from command line (CMD)
We can reboot a Windows computer from command line using the in-built shutdown command.В Below you can find syntax of this command for various use cases. The below commands work on Windows 7, Windows 8, Windows 10 and all other server editions.
Command to reboot windows computer
The above command will set a time out of 30 seconds to close the applications. After 30 seconds, windows reboot will start.
If you want to reboot Windows with your own time out value you can use the below command.
To shutdown a Windows computer
To abort computer reboot
If you have issued a reboot command and have changed mind, you can stop Windows reboot by running the below command.
When you run this, you would see a pop up window at the right bottom part of the screen(near system tray) that shows the message “The scheduled shutdown has been cancelled”.
To force reboot by closing applications without warning
Open the shutdown GUI
Add reason for the reboot of the computer
Reboot Windows using WMIC commands:
Reboot windows using WMIC
You can run the below wmic command to reboot Windows OS.
Is the abort command supposed to work if one has issued the reboot from GUI. I have tried this on my Windows 7 Ultimate, it does not seem to be working. it says ‘no shutdown was in progress’
Abort works only when you had issued the reboot/shutdown using the command. GUI actions are not aborted by /a option.
I’ve just attempted all commands from Windows 7 Ultimate install disk (used as recovery disk) and I obviously have a fault with my disk trying to load the Windows installation volume, I’ve launched command prompt via shift F10 as the GUI was not responding or should I say it had a never ending hour glass, trying a force shut down resulted in ‘the function is unknown’ proceeded with some numerical digits inside of closed brackets?
Shutdown /a is very handy when windows update tries to force reboot your computer. You can run this command and cancel the reboot if you don’t want the reboot to happen at that time.
How do I shutdown, restart, or log off Windows via a bat file?
I’ve been using Remote Desktop Connection to get into a workstation. But in this environment, I cannot use the power options in Start Menu. I need an alternative way to shutdown or restart.
How do I control my computer’s power state through the command line?
10 Answers 10
The most common ways to use the shutdown command are:
- shutdown -s — Shuts down.
- shutdown -r — Restarts.
- shutdown -l — Logs off.
shutdown -h — Hibernates.
Note: There is a common pitfall wherein users think -h means «help» (which it does for every other command-line program. except shutdown.exe , where it means «hibernate»). They then run shutdown -h and accidentally turn off their computers. Watch out for that.
shutdown -i — «Interactive mode». Instead of performing an action, it displays a GUI dialog.
The commands above can be combined with these additional options:
- -f — Forces programs to exit. Prevents the shutdown process from getting stuck.
- -t — Sets the time until shutdown. Use -t 0 to shutdown immediately.
- -c — Adds a shutdown message. The message will end up in the Event Log.
-y — Forces a «yes» answer to all shutdown queries.
Note: This option is not documented in any official documentation. It was discovered by these StackOverflow users.
I want to make sure some other really good answers are also mentioned along with this one. Here they are in no particular order.
How to restart Microsoft Windows
Restarting your computer is necessary for many common tasks, including installing new software and performing Windows Updates. This page contains multiple methods for restarting Windows. To proceed, select the method you would like to use from the list below or read through each section individually.
If the computer is frozen or the keyboard and mouse do not work, press and hold down the power button until the computer turns off. Once the computer is off, you can turn the computer back on to restart the computer.
If the computer has a blue screen or another error, try the Ctrl + Alt + Del shortcut method of rebooting.
Restarting from the Windows desktop
In any version of Windows, navigate to the desktop and press Alt + F4 on your keyboard. Doing so brings up a menu similar to the one displayed below. Click the down arrow for the drop-down list, select Restart, and click OK.
Restarting through the Start menu
Windows 10
The Start menu returns in Windows 10, allowing users to easily access the power options again.
- Click Start in the lower-left corner of the screen.
- Click the Power option.
- In the Power menu, select the Restart option.
Windows 8 and 8.1
Neither of these versions of Windows has the Start menu. However, with the 8.1 update, Microsoft added the power options button to the upper-right corner of the Start screen that allows users to restart their computer quickly. Click the power options icon (squared in red in the image below) and select Restart from the drop-down menu that appears.
Windows Vista and 7
In both Windows Vista and Windows 7, users may restart their computer through the Start menu using the following steps:
- Click Start in the lower-left corner of the Windows desktop.
- Locate and click the right arrow (shown below) next to the Shut down button.
- Select Restart from the menu that appears.
Windows XP and prior versions
- Click Start in the lower-left corner of the screen.
- Click the Shut Down button.
- Select Restart in the drop-down menu that appears.
- Click OK.
Using Ctrl+Alt+Delete to restart
If you press the Ctrl + Alt + Del keys on your keyboard simultaneously, it brings up an administrative menu. This menu differs between versions of Windows, but each one allows users access to the Restart function. Instructions for each version are shown in the following sections.
If the computer has a blue screen or another error, try the Ctrl + Alt + Del method of rebooting.
Windows 10
In Windows 10, pressing Ctrl + Alt + Del takes you to the Windows lock screen. To restart Windows:
- Locate and click the power icon in the lower-right corner of the lock screen. It should be the icon furthest to the right.
- Select Restart from the menu that appears.
Windows 8
Users of the Windows 8 will be taken to the Windows lock screen upon pushing Ctrl + Alt + Del . To restart Windows:
- Locate and click the black power button in the lower-right corner of the screen.
- Select Restart from the menu that appears.
Windows Vista and 7
In Windows Vista and 7, pressing Ctrl + Alt + Del takes users to the Windows lock screen containing several options. In the lower-right corner, there is a red button with an arrow next to it. Clicking this button opens a list of shutdown options, as you can see in the image. To restart your computer using this menu:
- Click the red arrow to open the menu.
- Select Restart to reboot your machine.
Windows XP and prior
In Windows XP and earlier, Ctrl + Alt + Del brings up the Windows Security screen. To restart:
- Click the Shut Down button.
- In the new window that appears, click the down arrow and select Restart from the drop-down menu.
- Click OK.
Using the Windows command line
You can shut down or restart a Windows computer using the Windows command prompt by following the steps below.
- Open the Windows Command Prompt.
- To shut down Windows, type shutdown -s and press Enter .
- To restart Windows, type shutdown -r and press Enter .
If you are accessing Windows on a computer through a remote desktop connection and execute the shutdown or restart command, the remote desktop connection will be terminated. If you executed the restart command, you can reconnect to that computer once it has restarted. If you executed the shutdown command, you can’t reconnect to and start up that computer remotely.
How to reboot from an error message
If the computer encounters an error, you can reboot or restart the computer by pressing the Ctrl + Alt + Del keys all at the same time. If these keys do not work, you can also perform the physical restart mentioned below.
Physical restart with button on computer
You can use the computer’s power button to restart. Press the power button once and wait for the computer to shut down. Press the power button again to turn the computer back on.
If your computer is frozen or does not turn off, press and hold the power button for five seconds to shut the computer off. This action is known as a hard reset and should only be done if all of the above options do not work.
Some computers also have a reset button next to or below the power button.
The Core Technologies Blog
Our Software // Windows Services // 24×7 Operation
Essential Tools for Windows Services: The NET Command
If you manage Windows Services and are comfortable working from the command line, then the Windows NET.EXE command should be in your toolkit. Use it to easily start, stop, pause or restart any service from an elevated command prompt, or in a convenient script/batch file.
Using NET to stop a Windows Service
To stop a service, run:
where is the name of the service. Be sure to enclose it in quotes if it contains a space!
For example, to stop the Print Spooler service (named “Spooler”), run:
Here is what it looks like on our Windows Server 2016 computer:
Notice that the NET command will wait for the service to stop before continuing. The only exception is when the service is unresponsive or takes more than 30 seconds to comply.
Starting a Windows Service with NET
To start an idle Windows Service, run:
If all goes well, your service (and any other service it depends on to operate) will be started after a few seconds:
How to Restart a Windows Service with NET.EXE
To restart a service, say from a batch file, chain the “net stop” and “net start” commands together like this:
NET will also Pause and Resume Windows Services
Not all services support pause and resume, but if you have one that does, NET can come in handy there as well.
To pause a service, type:
To resume a paused service, run:
You may also like.
28 Responses to Essential Tools for Windows Services: The NET Command
On using the NET command in a batch to restart I recommend adding time for the services to react. I’ve done this for one of my services that tends to hang. See below;
@ECHO.
@ECHO Stopping services, please wait for 10 seconds…
@ECHO OFF
REM Stop Service
NET STOP ServiceNameHere
REM The following is a timer to allow for server RAM to clear after the service has stopped
REM Use the numerical value within the ‘timeout’ command line to control how many seconds the pause will be.
TIMEOUT /t 10 /NOBREAK
ECHO.
NET START ServiceNameHere
I have a query if I need to start the multiple services and those service is taking more than 30 seconds to come up then how can i achieve that as currently its failing with error “‘net’ timed out after 30 seconds”.
Appreciate your early response. thanks
Hi. We recommend creating a batch file that uses the SC command to stop the service and check on it later.
To stop the service with SC, use:
SC STOP servicename
To check if a service was successfully stopped (after you wait for longer than 30 seconds), use the following command:
SC QUERY servicename | FIND “STATE” | FIND “STOPPED”
It will set the %ERRORLEVEL% variable to 1 if the service is not in the Stopped state.
This article may provide additional guidance.
I need a script to test users ability to start a service. Multiple users on multiple servers. Can i do that with SC or NET commands?
If you don’t mind attempting to start the service, you can also use NET START and search for errors, as shown in the example on this page.
sir net stop telnet how to use this cmd
Make note that if the service name is two words or more you must enclose the name with quotation marks. Took me a while to find that!
I want to restart services on multiple windows servers and it take around 1 minute to be stopped . I tried to use NET STOP but its not waiting and just executed next command to start . Can someone please help me with the exact script which i can use to restart services on multiple servers.
NET STOP will only wait for about 30 seconds for the service to stop. If a service takes longer than a few seconds, NET will fail with an “Unable to wait” message.
Unfortunately there is no way to tell NET STOP to “wait longer”. And the SC utility won’t be any help as it doesn’t even attempt to wait.
We recommend using the “safeServiceStop.bat” (or “safeServiceRestart.bat”) batch file described in this article.
Save the batch file to your file system and call it from your existing batch file. Note that you should add “localhost” when calling the new batch file. For example, to stop a service called “Spooler”, use
safeServiceStop localhost Spooler
Note that the recommended solution will wait indefinitely for the service to stop. If the service never stops, your script will hang.
UPDATE 8/27/2018: We have created a free command line utility (called ServicePilot) that will wait for as long as you like when stopping the service. You can use it instead of the batch file recommended above — it’s a much simpler alternative.
Be sure to specify an appropriate value for the “-wait” flag when using ServicePilot. For example, to stop the Spooler service when it may take 5 minutes (300 seconds) to comply, use:
Note that the service will be forcibly terminated if it doesn’t stop gracefully in the given time frame.
Stopd service Tobii. It does not accept the Net Start command, and Sc start, says that the command is invalid, service name (Tobii Service)
What command are you using to stop Tobii?
Make sure you are specifying the name of the service. And enclose the name in quotes if it contains a space!
It was right, I was putting the name without (“) hence it was wrong, now it worked out . Net start” Tobii Service “
If I use net stop and and net start on a special service that have stoped working correct it doesn’t help, it still working incorrect.
But when restart the same service from services.msc it reset the service correct. What is the difference?
(service name is in one word, so not the quotes problem..)
Does NET STOP/START print any error messages to the console? Perhaps it is failing and not actually stopping/starting the service.
A common problem: NET STOP/START will fail if you are not running with sufficient rights. Make sure that you are working in an elevated prompt (started with “Run as Administrator”).
Thank you. No error messages, it just says that the servicie is stopped. And yes I run it elevated.
I will try timeout from the first comment next time i’m at the actual computer.
A really common problem when the net or SC commands and some custom services is that you have to specifiy the “Service Name” not the “Display Name” Many times they are the same but not always. Right click on the service in services.msc to see the two on the general tab and make sure you are doing “Net Start servicename” – and as said above, you still have to put it in quotes if it’s got spaces.
You can change the name with sc to make it easier if you want but obviously, this might be a bad idea with system/windows services.
BTW, I know the article actually does say this but the link for “name of service” which explains this is kind of subtle and I think people might be missing that.
Thank you for pointing out the important difference between “Service Name” and “Display Name”.
Yes, we do mention the need to use the “Service Name” in the article, but maybe there is a way to make it more prominent. We’ll think about it — let us know if you have any ideas that don’t detract from the main focus of the article (using NET).
Note that our free ServicePilot utility (a more fully-featured alternative to NET.EXE) removes the name confusion by accepting both the “Service Name” and the “Display Name”. You can use either one!
Spotlight on Art. Amazy due. This got me the possibly best task ever. exactly 30 seconds after I log on, simultaneous to the desktop resolving over my SSD run system I am watching a slightly modded version of your script rock the Synergy service off then on in about 20 seconds flat. I have been, hitherto on every login for
6 months since getting Synergy having to click a taskbar icon for Synergy, then stop and start in the program, because it won’t start client clicks until the service restarts. Simply the best. Here is my modded script:
@ECHO.
@ECHO Stopping services, please wait for 10 seconds…
@ECHO OFF
REM Stop Service
NET STOP Synergy
TIMEOUT /t 10 /NOBREAK
ECHO.
NET START Synergy
forgot to thank YOU core technologies, for your recent help in getting my TASK SCHEDULER started..albeit on a completely different computer than the one mentioned above.
If the service isn’t running the START won’t happen unless you format it like this:
net stop
net start
If the service isn’t running, the first line will throw and error, but the second line will pick up and start the service for you.
I want to restart some specific service for a specific time every week.
if I used the above commands given will it work?
and if it fails to stop the service by-case will I get any email notification or is there any way to get the notification through email to me if something goes wrong?
also if the restart thorough the batch file get succeeded, will I get notified through anyway instead logging in & checking windows logs
Yes — you can use the above NET commands in conjunction with the Windows Task Scheduler to restart a specific service at a specific time. We’ll add a blog article digging into the details and let you know when it’s up.
Unfortunately there is no simple, built-in way for Windows to notify you if a service operation succeeds or fails. Some administrators of large sites have set up tools that monitor the Event Log for important events and deliver alerts, but that may be overkill if you are not in an enterprise environment.
Let us know if that solution doesn’t work for you.
I have got two batch files written within my application to stop and start a windows service.
Is there a way for me to check the status of the said service (whether it is stopped or not) and restart the same at a specific time during the day?
For more clarity –
The application service stops at, say 11pm at night and starts at 11:15pm again.
Is there a way to write time bound conditions for restarting a script excluding the duration 23:00-23:15?
Apologies if it doesnt make much sense.
Hi. You can use this simple batch file to check if a service is running or not:
Save those lines to a new .BAT file and pass the name of your service (not the display name) as the first parameter.
With regards to stopping at a specific time and restarting at another time, we recommend using the Windows Task Scheduler.
Create a basic task that stops your service at 11 PM (a batch file running NET STOP) and another that starts the service at 11:15 PM (with NET START).
The process is outlined in the “Restart multiple times per day (using the Windows Task Scheduler)” section of this related article.