Shutdown Restart and or Log Off in a Bat File

shutdown command is used to shut down, restart or log off the computer.

  • Shut down the PC
  shutdown -s
  • Restart the PC
  shutdown -r
  • Log off the PC
  shutdown -l
  • Hibernate the PC
  shutdown -h

shutdown Command Options

options Description
/i Display the GUI (must be the first option)
/l Log off
/s Shutdown
/sg Shutdown and on the next boot restart any registered applications.
/r Restart
/g Restart, after restarting restart any registered applications.
/a Abort a system shutdown during the time-out period.
/p Turn off the local computer with no time-out or warning
/h Hibernate
/e Document the reason for an unexpected shutdown of a computer.
/hybrid Perform a shutdown of the computer and prepare it for fast startup. Windows 8+ Must be used with /s (shutdown) option.
/f Force running applications to close.
/soft Perform a soft shutdown/restart/logoff. Windows 10 This will ask programs to close and wait for them to end.
/fw Combine with a shutdown option to cause the next boot to go to the firmware user interface. Windows 10
/o Go to the advanced boot options menu and restart the computer. Must be used with /r option. Windows 8+
/t <second> Time until system shutdown in seconds.
/c <message> Shutdown message that appears on screen before the shutdown
/y Force a yes answer to all shutdown queries.
Contribute
DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.