123

Remotely Scheduling Tasks by Command Line for Windows XP

Mark Schneider
As an Administrator I've often used scripts to automate regular tasks. Scheduling tasks for a remote PC on a network is a very useful thing to have in any administrator's war chest. However, how to schedule tasks remotely isn't very well documented. Command line administration is still a very important skill often over looked by today's administrators that look mainly for 3rd party tools with GUI interfaces. Part of being an effective administrator is using the command line effectively.

Let's start by looking at what a scheduled task is. A scheduled task is an application or tool set to run at specified daily, weekly, monthly or even on a specific day of the month or week. These tasks also run with system account credentials to accomplish a task that a non administrative account doesn't have rights to accomplish. Knowing how to set these tasks by command line allows an administrator write scripts to add these tasks to many machines easily without having to set the task on each individual PC individually.

Introduction to the "at" command. Scheduling tasks through the command line, either locally or remotely, depends on an understanding of the "at" command. The command is quite literal once you know its meaning, let's look at an example "at" command:

C:\> at 4:00 defrag.exe

If you look in your local task scheduler you'll see this automatically created a task to run the defragment tool the next time 4am comes around. Let's break it down [bracketed terms are implied by the syntax],

at 4:00
This runs the task a single time. It also creates and runs the task as "System". So, how do you get that same command to create a task on a remote machine? Let's take a look:

C:\>at \\Name 4:00 defrag.exe

This creates the exact same task on a remote machine as it created on your local machine. It also creates and runs the task using the system account just like the locally created one. One note: the account you are using when you run this command must have administrative rights to the remote system, otherwise the command will fail with an error. The remote system also needs to have "File and Print Sharing" enabled, though this is enabled by default when you join a PC to a domain. The At command runs on 24-hour time, so 1am would be 1:00 but 1pm would be 13:00.

This should give you a basic understanding of how to schedule tasks from the command-line.

Published by Mark Schneider

Technology Director, Technical Consultant, Network Engineer, Server Engineer, Software Developer, Online Game Addict. Try everything, you never know what you'll be good at.  View profile

1 Comments

Post a Comment
  • Mark Schneider8/25/2007

    Looks as though the literal translation got eaten somewhere along the line. Should read like the following:

    AT 4:00(am) (run)defrag.exe

    you can also delete a scheduled task using the following syntax:

    at \pcname 1 /delete

    The number 1 denotes the task ID as seen in the task schedule

To comment, please sign in to your Yahoo! account, or sign up for a new account.