Shutdown or Restart Computers Remotely
If you’ve ever wanted to schedule your computer to shutdown or restart after a period of time or simply at a specified time of the day you can do this quite easily using the Task Scheduler and the Shutdown.exe command.
Introduction
Continue with this article if you're after information on using the Task Scheduler to setup shutdown and restart jobs.
If you're after information on how to use Shutdown and CMD you probably want this article: Restart or Shutdown Computers Using CMD and SHUTDOWN Commands from the Command Line
The Real Introduction
There may be instances when you may want to runThe following scenarios will tell you exactly how to use Shutdown.exe to setup your Shutdown and Scheduled Tasks jobs to take care of most of your tasks.
The general syntax for the shutdown.exe command is as follows:
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername]
[-t xx] [-c "comment"] [-d up:xx:yy]
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)
Use shutdown.exe to shutdown your computer in 30 seconds
- Click Start
- Click Run
- In the Run box, type cmd and click OK
- A black box (command shell) shows up and inside it type: shutdown -s -t 30 and hit Enter
Use shutdown.exe to shutdown a remote computer in 1 hour (60 minutes) seconds
If you would like to shutdown a remote computer you can also achieve this using the shutdown command. This command will allow you to use the –m \\computer switch to designate the computer to shutdown. Rember also that the -t (time) command uses seconds as the unit of time, so all your times will need to be in seconds. In our example 1 hour (60 minutes) will be 3600 seconds.
In our example, say we would like to shutdown a computer named MyOtherComputer in 60 minutes (3600 seconds):
- Click Start
- Click Run
- In the Run box, type cmd and click OK
- A black box (command shell) shows up and inside it type: shutdown -s –m \\MyOtherComputer-t 3600 and hit Enter
Using Sheduled Tasks and Shutdown.exe to automate your Computer
Lets say for a second that you would like to shutdown/reset your/another computer on a regular basis. For instance, you might have a requirement to configure your computer to shutdown at 3am every night regardless of whether you are there or not.
The easiest way to do this is to setup a Sheduled Task using the Sheduled Tasks utility in Windows.
To open Scheduled Tasks:
- Click on Start
- Click All Programs
- Click Accessories
- Click System Tools
- Click Scheduled Tasks

To Create a new Scheduled Task:
- Double click on the "Add Scheduled Task" icon
- In the Scheduled Task Wizard click Next
- Click Browse and in the filename box type c:\windows\system32\shutdown.exe and Click OK
- Give your task a name, such as Shutdown at 3am
- Select Daily and Click Next
- Enter the start time to be 3:00 AM and click Next
- Enter the username and password which will be used to execute the task and click Next
- Click Finish
You will be presented with a Scheduled Tasks window as follow:

We will now need to edit this task slightly to include our custom parameters, such as -m and -t.
To modify the command line of the shutdown.exe task:
-
Right click your newly created Task, in our example "Shutdown at 3am" and select Properties
-
You will be presented with the Edit Shutdown at 3am dialog, notice the command string in the Run text box below.
-
In the Run text box, add to the end of the command string -s -t 0 and click Apply
-
If you're asked to re-enter the credentials under which the tast will run, do so. Click OK
-
Your Shutdown at 3am Task should look exactly as it is show below. Take care to ensure that all of the command parameters are quoted as they are below in the Run textbox.

References
Restart or Shutdown Computers Using CMD and SHUTDOWN Commands from the Command Line
/articles/shutdown-or-restart-computers-remotely.aspx
[Permalink] - Updated: Sunday, February 21, 2010
 
Articles of Interest