Introduction
Sometimes having a .bat file to restart/shutdown or logoff could be helpful. One common use case is when you need to restart or shutdown while using remote desktop (buttons will be disabled). In this article we will use the shutdown command that allow us to restart/shudown or logoff.
Using shutdown command
The batch file should contain a call to the shutdown command with the proper options.
For example for inmediate shutdown while connected using a remote desktop session:
shutdown -t 0 -r -f
If you want to add a 30 seconds to start the shutdown:
shutdown -t 30 -r
Here we list most of the common options for shutdown
command:
shutdown -r
â restartsshutdown -s
â shutsdownshutdown -l
â logoffshutdown -t xx
â wherexx
is number of seconds to wait till shutdown/restart/logoffshutdown -i
â gives you a dialog box to fill in what function you want to useshutdown -a
â aborts the previous shutdown command....very handy!shutdown -h
â hibernate.
Shutdown command on remote sessions
When you are on a remote session (remote desktop), add the -f option to force the reboot. If you don't add -f, the session may close and can hang the windows.