Shutdown or Restart Windows from the CMD Command Line
-
With the bizarre, cumbersome interface of “Metro” in Windows 8 and Server 2012, we need a faster way to shutdown or reboot our computers. Command line shutdowns have always been available but few people have every used them before now. Now they are common both because Windows 8 makes the graphical interface so cumbersome that using the command line is easier and because we often, with Windows Server 2012, have no GUI installed.
To reboot we use the shutdown command with the /r flag:
shutdown /r
To shutdown and power off the machine we use the /s flag:
shutdown /s
In both cases the command gives a one minute countdown before actually taking effect. We can speed that up with the -t option. This stands for time and the option after it is the number of seconds to delay. The default, as you can guess from the statement above, is sixty seconds. To reboot immediately:
shutdown /r -t 0
Originally published on my Windows administration blog in 2013 here: http://web.archive.org/web/20130929034913/http://www.scottalanmiller.com/windows/2013/03/24/shutdown-or-restart-from-the-command-line/
-
@scottalanmiller said in Shutdown or Restart Windows from the CMD Command Line:
With the bizarre, cumbersome interface of “Metro” in Windows 8 and Server 2012, we need a faster way to shutdown or reboot our computers. Command line shutdowns have always been available but few people have every used them before now. Now they are common both because Windows 8 makes the graphical interface so cumbersome that using the command line is easier and because we often, with Windows Server 2012, have no GUI installed.
To reboot we use the shutdown command with the /r flag:
shutdown /r
To shutdown and power off the machine we use the /s flag:
shutdown /s
In both cases the command gives a one minute countdown before actually taking effect. We can speed that up with the -t option. This stands for time and the option after it is the number of seconds to delay. The default, as you can guess from the statement above, is sixty seconds. To reboot immediately:
shutdown /r -t 0
Originally published on my Windows administration blog in 2013 here: http://web.archive.org/web/20130929034913/http://www.scottalanmiller.com/windows/2013/03/24/shutdown-or-restart-from-the-command-line/
I always mess this up and try using the /h flag for some reason. This is a good reference to have.
-
I always throw /f in too, just because I don't take no for an answer.
-
@coliver said in Shutdown or Restart Windows from the CMD Command Line:
I always mess this up and try using the /h flag for some reason. This is a good reference to have.
A little Linux "halt" sneaking in there?
-
I use the command line option to shutdown restart quite often. My brother wrote a script some time ago to that prompted you for what you wanted to do, even abort it. If I can find it, I'll post it.
-
@echo off setlocal :REQUEST set /p REQUEST="Logoff, Shutdown, Reboot or Abort? L/S/R/A " if /i %request%==l goto logoff if /i %request%==s goto timer if /i %request%==r goto timer if /i %request%==a goto abort goto REQUEST :logoff shutdown -f -l goto exit :abort shutdown -a goto exit :timer set /p TIMER="Wait how many seconds? " if /i %request%==s shutdown -f -s -t %timer% if /i %request%==r shutdown -f -r -t %timer% :exit