Windows OS Hub
  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange

 Windows OS Hub / Windows 10 / Shutdown/Restart Windows using Command Prompt (CMD)

July 27, 2020 Questions and AnswersWindows 10Windows Server 2016

Shutdown/Restart Windows using Command Prompt (CMD)

The Shutdown.exe is an built-in Windows command line tool that allows to reboot, shutdown, put your computer to sleep, hibernate or end a user session. In this guide, we’ll show the basic examples of using the shutdown command in Windows. All commands discussed above are run in the Run dialog box — Win+R ->, in the command prompt (cmd.exe) or in PowerShell.

The shutdown command has the following syntax:
shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f] [/m \\computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]
The shutdown.exe command in Windows

As you can see, the command has quite a lot of options, and can be used to shutdown/restart a local or remote computer.

How to Shutdown Windows Using the Command Prompt?

To shutdown Windows your computer, use the shutdown command with the /s key.

shutdown /s

Reboot Windows from the CMD

In order to reboot your computer, use the /r parameter. After running it, Windows will be will gracefully restarted.

shutdown /r

shutdown /r -reboot windows from cmd

End a User Session

To end the current user session (logoff), run this command:

shutdown /l

shutdown /l - logoff current user

This command works in the same way as logoff.exe command.

How to Hibernate Windows?

To hibernate your computer, run this command:

shutdown /h

In the hibernate mode, the whole memory contents is written to the hiberfil.sys file on the local disk and the computer is put to sleep mode thus lowering the energy consumption

How to Notify Logged-on Users Before Reboot or Shutdown?

You can notify all logged-on Windows users about the upcoming shutdown/reboot of the computer or server by sending a message to all active sessions. As a rule, this feature is used on RDS servers with several users working on them at the same time in their own RDP sessions.

shutdown /r /c “This server will be restarted in 60 seconds.”

Delayed Shutdown/Reboot of a Computer Using the Timer

You can shutdown or restart the computer with a certain delay (on timer). Using the /t option, you can specify the time span after which the computer/server will be shutdown or rebooted. Thus you can provide your users some time to save open files and close the apps correctly. It is convenient to use this option together with the notify message. In this example we inform the users that Windows will be shutdown in 10 minutes (600 seconds).

shutdown /s /t 600 /c "The server will be shutdown in 10 minutes. Save your work!"

A user will see a notification about the planned shutdown:

You’re about to be signed out

windows shutdown command - You’re about to be signed out. Your Windows will shut down in 10 minutes

If the delay is too long, say, 100 minutes (6,000 seconds), a popup window appears in the lower right corner of the screen: You’re about to be signed out. Your Windows will shutdown in 100 minutes.

You’re about to be signed out. Your Windows will shut down in 100 minutes

Cancel Windows Shutdown or Restart

After running Windows shutdown or reboot command, the shutdown tool waits 60 seconds by default without doing anything. An administrator can cancel the restart or shutdown of the device by running this command during this time:

shutdown /a

After you cancel the shutdown, you’ll see the following popup window in the lower right corner of the screen: Logoff is cancelled. The scheduled shutdown has been cancelled.

Logoff is cancelled. The scheduled shutdown has been cancelled

Force an Immediate Restart of the Computer

To shutdown or reboot a computer immediately without waiting for 60 seconds, specify 0 as a value of the /t parameter. For example, to restart the computer immediately:

shutdown /r /t 0

The /f key is very important. I use it almost always when shutting down or restarting Windows servers. This attribute forces close all running programs and processes without user confirmation (we won’t wait till the users confirm closing all applications on the RDS server since we can never get it).

The next command will restart the computer and automatically run all registered apps after the restart (apps registered in the system using RegisterApplicationRestart API are meant here).

shutdown /g

Hot to Remotely Shutdown or Restart a Windows Computers?

You can reboot a remote computer if you have the network access to it, and the account you are using to run the shutdown command must be a member of the local administrators group on the remote computer (server):

shutdown /r /t 120 /m \\192.168.1.210

shutdown remote windows host

If all the conditions described above are met, but when running the shutdown command the error “Access denied (5)” appears, allow the remote access to the admin shares (C$, ADMIN$) on the remote computer by changing the value of LocalAccountTokenFilterPolicy parameter to 1.

reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "LocalAccountTokenFilterPolicy" /t REG_DWORD /d 1 /f

If you need to restart multiple computers remotely, you can save the list of computers to a text file and run a remote reboot of all computers using a simple PowerShell script:

$sh_msg = "Your computer will be automatically restarted in 10 minutes. Save your files and close running apps"
$sh_delay = 600 # seconds
$computers = gc C:\PS\PC-list.txt
foreach ($comp in $computers)
{
& 'C:\Windows\System32\SHUTDOWN.exe' "-m \\$comp -r -c $sh_msg -t $sh_delay"
}

Shutdown Command Graphical Interface

Those who don’t feel comfortable to work in the command prompt can use the graphical interface of the shutdown.exe command. To call the remote shutdown dialog, use the command:

shutdown /i

remote shutdown GIU dialog

As you can see, you can add multiple computers in the remote shutdown dialog to be rebooted/shutdown, specify the notification text and specify the reason of the shutdown to be saved in the Windows event log.

How to Reboot Computer Using Shortcut?

To make it more convenient to users, you can create shortcuts to restart or shutdown a computer with the required settings on the desktop. The shortcut may be useful when you need to restart the computer from the RDP session when there are no options to restart or shutdown the computer in the Start menu.

shutdown shortcut

If you want your computer or server to restart/shutdown at the specific time, you can add the shutdown command with the certain parameters to Windows Task Scheduler (taskschd.msc).

For example, this Scheduler task will restart the computer daily at 12 AM.

shedule a shutdown task

Or you can create a new Scheduler task with PowerShell:

$Trigger= New-ScheduledTaskTrigger -At 00:00am -Daily
$User= "NT AUTHORITY\SYSTEM"
$Action= New-ScheduledTaskAction -Execute "shutdown.exe" -Argument "–f –r –t 120"
Register-ScheduledTask -TaskName "RebootEvertyNight_PS" -Trigger $Trigger -User $User -Action $Action -RunLevel Highest –Force

0 comment
0
Facebook Twitter Google + Pinterest
previous post
How to Allow Non-Admin Users to Start/Stop Windows Service?
next post
Configuring SSH Key-Based Authentication on Windows 10/ Server 2019

Related Reading

Preparing Windows for Adobe Flash End of Life...

January 22, 2021

How to Disable/Remove Thumbs.db File on Network Folders...

January 21, 2021

USB Device Passthrough (Redirect) to Hyper-V Virtual Machine

January 15, 2021

Windows 10: No Internet Connection After Connecting to...

January 13, 2021

Configuring Software RAID on Linux Using MDADM

January 11, 2021

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange
  • Windows 10
  • Windows 8
  • Windows 7
  • Windows Server 2016
  • Windows Server 2012 R2
  • Windows Server 2008 R2
  • PowerShell
  • VMWare
  • MS Office

Recent Posts

  • Preparing Windows for Adobe Flash End of Life on December 31, 2020

    January 22, 2021
  • Checking User Logon History in Active Directory Domain with PowerShell

    January 22, 2021
  • How to Disable/Remove Thumbs.db File on Network Folders in Windows?

    January 21, 2021
  • MS SQL Server 2019 Installation Guide: Basic Settings and Recommendations

    January 19, 2021
  • USB Device Passthrough (Redirect) to Hyper-V Virtual Machine

    January 15, 2021
  • Windows 10: No Internet Connection After Connecting to VPN Server

    January 13, 2021
  • Updating the PowerShell Version on Windows

    December 24, 2020
  • How to Enable and Configure User Disk Quotas in Windows?

    December 23, 2020
  • Restoring Deleted Active Directory Objects/Users

    December 21, 2020
  • Fix: Search Feature in Outlook is Not Working

    December 18, 2020

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • Fix: RDP Authentication Error Has Occurred – The Function Requested Is Not Supported
  • How to Configure MariaDB Master-Master/Slave Replication?
  • How to Mount Google Drive or OneDrive in Linux?
  • “The update is not applicable to your computer”: Windows Update Error
  • Adding VLAN Interface in CentOS/Fedora/RHEL
  • SSL Error: This Site Can’t Provide a Secure Connection in Chrome, Opera & Chromium
  • Install and Configure PostgreSQL on CentOS/RHEL
Footer Logo

@2014 - 2018 - Windows OS Hub. All about operating systems for sysadmins


Back To Top