How can I reboot using the command line or script? ~ Ask The Admin

Monday, December 17, 2007

How can I reboot using the command line or script?

start run windowsIf you are like reader Miguel and you want to reboot your Windows XP or Vista machine from a .bat file, here is the command to do it:

shutdown -r -f -t 0

LifeHacker showed you this command here advertising it as a fast shutdown command.

shutdown -f -t 0

Be warned - it forces apps to close even if you have not saved your work document!

There is also a command to cancel an impending reboot. This can be helpful if the system initiated it after an update.

shutdown -a

So the -f forces close, -r reboots, -t 0 is how long in seconds before reboot or shutdown and -a cancels it. You can log off a user with -l and -m lets you hit up a remote machine! Go forward young admin and get to scripting. Check out how I use scripts with outlook here. Pretty nifty stuff, eh?

Shutdown

Allows you to shut down or restart a local or remote computer. Used without parameters, shutdown will logoff the current user.

Syntax

shutdown [{-l|-s|-r|-a}] [-f] [-m [\\ComputerName]] [-t xx] [-c "message"] [-d[u][p]:xx:yy]

Parameters

-l : Logs off the current user, this is also the defualt. -m ComputerName takes precedence.

-s : Shuts down the local computer.

-r : Reboots after shutdown.

-a : Aborts shutdown. Ignores other parameters, except -l and ComputerName. You can only use -a during the time-out period.

-f : Forces running applications to close.

-m [\\ComputerName] : Specifies the computer that you want to shut down.

-t xx : Sets the timer for system shutdown in xx seconds. The default is 20 seconds.

-c "message" : Specifies a message to be displayed in the Message area of the System Shutdown window. You can use a maximum of 127 characters. You must enclose the message in quotation marks.

-d [u][p]:xx:yy : Lists the reason code for the shutdown.

[Via Microsoft]

_TheDontMakeMeShutYouDownAdmiN_