How to Shutdown Restart and or Log Off in a Bat File

Jinku Hu Feb 02, 2024
How to 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.
Author: Jinku Hu
Jinku Hu avatar Jinku Hu avatar

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.

LinkedIn Facebook