ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Shutdown or Restart Windows from the CMD Command Line

    IT Discussion
    windows command line cmd
    4
    6
    2.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scottalanmillerS
      scottalanmiller
      last edited by

      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/

      coliverC 1 Reply Last reply Reply Quote 1
      • coliverC
        coliver @scottalanmiller
        last edited by

        @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.

        scottalanmillerS 1 Reply Last reply Reply Quote 1
        • crustachioC
          crustachio
          last edited by

          I always throw /f in too, just because I don't take no for an answer.

          1 Reply Last reply Reply Quote 4
          • scottalanmillerS
            scottalanmiller @coliver
            last edited by

            @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?

            1 Reply Last reply Reply Quote 3
            • gjacobseG
              gjacobse
              last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • gjacobseG
                gjacobse
                last edited by

                @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
                
                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post