Windows XP [Electronic resources] : Visual Quickstart Guide, Second Edition

Chris Fehily

نسخه متنی -صفحه : 247/ 211
نمايش فراداده

Scheduling Tasks

Periodic maintenance and backups aren't useful unless they actually occur periodicallyand human memory often fails here. Scheduled Tasks, which starts and runs each time you start Windows, can schedule programs to run according to a schedule that you specify.

Now things become more technical. It does you no good simply to

open a program on schedule; you must specify the command name and command-line options that make it run to completion without your intervention. A

command name is a program's filename as typed at a command prompt (choose Start > All Programs > Accessories > Command Prompt). Disk Defragmenter's command name is defrag, and Backup's is ntbackup, for example.

Command-line options, or

switches, are space-separated parametersprefixed by a - or / characterthat follow the command name and control that command's behavior. Search for

command-line reference in Help and Support Center to find commands, their switches, and examples (Figure 19.30 ).

Figure 19.30. Help and Support Center's description of the defrag command and its command-line options. The command defrag C: /f defragments your C: drive, for example

To schedule a new task:

1. Choose Start > All Programs > Accessories > System Tools > Scheduled Tasks.

2. Right-click an empty area in the Scheduled tasks window; then choose New > Scheduled Task (Figure 19.31 ).

Figure 19.31. The first few times that you schedule a new task, you may want to double-click Add Scheduled Task for a wizard to walk you through the process.

3. Type a name for the task; then press Enter.

4. Double-click the new task.

5. On the Task tab (Figure 19.32 ), in the Run box, type the command to run as the scheduled task.

Figure 19.32. In this tab, specify the program that you want to run on a schedule.

If necessary, include command-line options and a pathname (see "Exploring Your Computer" in Chapter 5). If the pathname includes spaces, type double quotation marks (") around the entire command.

If the command requires an Administrator to run, and you're not one, type an Administrator's user name in the Run As box; then click Set Password. (Blank passwords are forbidden.) If you're on an XP Pro domain, type

domain_name\user_name .

6. On the Schedule tab (Figure 19.33 ), specify when and how often to run the task.

Figure 19.33. Click Advanced if you want to set a task's start and end date or make it run repeatedly at specified intervals.

7. On the Settings tab (Figure 19.34 ), set the conditions under which the task will run.

Figure 19.34. Don't just accept some of the nonsensical factory settings on this tab; you should stop a task if it runs for a few hours (not 72, as Microsoft suggests). The bottom section is for laptop users.

8. Click OK (or Apply).

Now the task will run according to schedule, even if somebody else (or nobody) is logged on.

Tips

Choose View > Details to see schedule information for all tasks, including the earlier and next run times. A 0 or 0x0 in the Last Result column means that a task ran successfully; any other value represents an error.

The Advanced menu offers some not-very-advanced commands. Use it to pause all scheduled tasks, shut down Task Scheduler, or notify you of missed tasks.

To run a task on demand, right-click it; then choose Run.

You can place multiple commands in a text file with a .bat extension and run this

batch file as a single task instead of running each command individually.

Double-click the taskbar clock to confirm that the system date and time on your computer are accurate. Scheduled Tasks relies on this information.

At the command prompt, type a command followed by -? (or /?) to see its command-line options. Type defrag -?, for example.

Command-prompt junkies can use the at command instead of Scheduled Tasks.