How to schedule your computer to run tasks automatically


Our building will have a power failure at a particular time. You may want your computer to stay on til just before the power goes out due to various reasons:


 



  • It may be a web or file server serving other clients around the world.

  • You may want to access it from a remote location

 


Choose Start->Control Panel->Scheduled Tasks. Right click (or hit the Context menu button on your keyboard) and choose Open. (this avoids the Scheduled Task Wizard)


 


Choose File->New->Scheduled task and give it a name. Hit Enter or dbl-click on it to tell it what to do. I want it to run the Shutdown command in a command prompt.


 


Be sure the Run As, password are set, so the task has the rights to run.


 


So type in “cmd /c shutdown –f –s” and schedule it as you like.


 


 


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)


 


Over the years, I’ve used the task scheduler to run various processes (like compiling or syncing) automatically.


 


 


On Vista, choose Control Panel->Admin Tools->Task Scheduler. Make sure to choose Task Scheduler Library from the treeview on the left to see tasks you create. You can easily just display a messagebox to your user. For example, you could make it display an annoying message every hour. Vista allows you to run a task at various events, such as Log On, StartUp, idle, etc.


 


 


There is also the AT command:


AT /?


The AT command schedules commands and programs to run on a computer at


a specified time and date. The Schedule service must be running to use


the AT command.


 


AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]]


AT [\\computername] time [/INTERACTIVE]


    [ /EVERY:date[,…] | /NEXT:date[,…]] “command”


 


\\computername     Specifies a remote computer. Commands are scheduled on the


                   local computer if this parameter is omitted.


id                 Is an identification number assigned to a scheduled


                   command.


/delete            Cancels a scheduled command. If id is omitted, all the


                   scheduled commands on the computer are canceled.


/yes               Used with cancel all jobs command when no further


                   confirmation is desired.


time               Specifies the time when command is to run.


/interactive       Allows the job to interact with the desktop of the user


                   who is logged on at the time the job runs.


/every:date[,…]  Runs the command on each specified day(s) of the week or


                   month. If date is omitted, the current day of the month


                   is assumed.


/next:date[,…]   Runs the specified command on the next occurrence of the


                   day (for example, next Thursday).  If date is omitted, the


                   current day of the month is assumed.


“command”          Is the Windows NT command, or batch program to be run.


 


But


 


See also


 


Task Scheduler


 


Windows Vista Task Scheduler


 


How To Use the Remote Shutdown Tool to Shut Down and Restart a Computer in Windows 2000


 


You Cannot Schedule a Windows XP-Based Computer to Shut Down and Restart by Using the AT Command with Shutdown.exe

Comments (7)

  1. MSDNArchive says:

    Your link for "Task Scheduler" is broken.

    Also, schtasks.exe is very useful as well! 🙂

  2. Calvin_Hsia says:

    thanks: i’ve fixed the link

  3. ravi says:

    i would like to shutdown all my computer’s every day at 8.00 pm.can any body help me how to schedule that.

  4. mircea says:

    Hi,

    In Windows XP if you run the AT command with /interactive option, you can log in as system user. (for example "at 0:00 /interactive cmd")

    In Windows Vista this does not work (interactive for system account). I tried schtasks and it runs the cmd command, but not in interactive mode. How can I run a program as system user in an interactive mode in Windows Vista?

    Thank you,

    Mircea

    PS. The command in Vista which I tried is:

    schtasks /create /sc once /tn myexplorer /tr "cmd.exe /c cmd.exe" /ru system /st 0:00

    and when you run the task it runs cmd.exe as system user, but not in interactive mode.

  5. flame says:

    SCHTASKS /Create [/S system [/U username [/P [password]]]]

       [/RU username [/RP password]] /SC schedule [/MO modifier] [/D day]

       [/M months] [/I idletime] /TN taskname /TR taskrun [/ST starttime]

       [/RI interval] [ {/ET endtime | /DU duration} [/K] ]  

       [/SD startdate] [/ED enddate] [/IT] [/Z] [/F]

       /IT                            Enables the task to run interactively

                                      only if the /RU user is currently

                                      logged on at the time the job runs.

                                      This task runs only if the user is

                                      logged in.

    but you need to use /RU (/RP) switches to specify user’s credentials in which context task will operate.

    i still didn’t find solution to add interactiv job for any user on Vista.

  6. Aj says:

    HI…….

              Im looking such a kind of software where we can set a time to launch the required software and do the work….. (it should have the recording ability ex: if i open a clean up software and strat cleaning.. after that i clean unwanted files and exit)… if any thing like this is there.. plz email me …..

    thank you

  7. MoNO says:

    How can i turn on my computer with scheduler?