Scheduled Tasks


Scheduled Tasks is found in the Control Panel and in the Start menu (All Programs, Accessories, System Tools, and Scheduled Tasks). Using the Scheduled Tasks, you can set up any program or script (or even open a document) to be run automatically at predetermined times. This utility is very useful for running system maintenance programs or your own scripts and programs when you can't be around to execute them manually.

TIP

You could even use the Scheduled Tasks to run a script that starts or stops a specific system service. The net command can be used to start and stop services using simple syntax:

 net start "service name here" 

or

 net stop "service name here" 

Most folks don't even need to think about this capability, but if you are a software developer and use a special debugging or testing service, this capability might be handy to start it up when you log in. Remember that there is no "when I log off" scheduler entry, so you can't automate shutting off the process when someone logs out.

You also can cause a specific script or program to run (1) when the system boots, (2) when a user (any user) logs on, or (3) when the system is idle. Why is this different from putting the script or program in the Startup group for All Users? Well, the Scheduled Tasks lets you specify the security context to use for this login task. For example, whenever a user logs on, you can have the Scheduled Tasks run a program with Administrative privileges to record information in a protected file. Using the Scheduled Tasks this way is similar to using the Run As option. (See Chapter 28, "Managing Users," for more details about Run As.)


NOTE

When the Scheduled Tasks runs a task as a different user, the logged-on user cannot see or interact with the program. Be sure that scheduled tasks can operate without user input and exit cleanly when they've done their work. And keep in mind that once an application or service is running, even if it was launched through a scheduled task, it still will affect system performance as if you ran it manually.


After you declare tasks to run, the Scheduled Tasks sits in the background, checking the computer's system clock, and when a predetermined time for a task rolls around, the Scheduled Tasks runs it as though executed from the specified user.

After you've defined a task to be executed, the Scheduled Tasks service automatically will launch at startup each time the computer boots. The Scheduled Tasks service does not significantly affect system performance. The service is required to monitor the time and other system events that are defined as triggers to launch applications, scripts, and so on. The Scheduled Task service cannot be configured to load based on the logged-on user because it is a systemwide service. Even if a user without scheduled tasks is logged in, a scheduled task from another user can execute in the background.

NOTE

Obviously, the computer has to be alive to run a task, so if you expect to do a disk cleanup at 4 a.m., be sure you've left the computer on. If you turn on the system at 4:01 a.m., you missed the execution. The scheduler will not inform you of missed launchings; you'll have to view the information in the Last Run Time column within the Scheduled Tasks window to figure it out for yourself.


TIP

If you upgraded from Windows 98/SE/Me/NT/2000 and had automated tasks assigned there, they should have been converted or imported to the Windows XP Scheduled Tasks automatically.


To assign tasks to the Scheduled Tasks, follow these steps:

1.

Run the Scheduled Tasks by choosing Start, All Programs, Accessories, System Tools, Scheduled Tasks. If you have any scheduled tasks, they appear in the list already.

2.

Click Add Scheduled Task to invoke a wizard that walks you though adding a new task. Click Next to see a list of programs (see Figure 27.1). If the program isn't listed in the resulting list, click the Browse button to find it. (For system-related applications, the most likely browse locations are in the \windows or \windows\system32 folders. For programs you've installed, try the Program Files subfolders.)

Figure 27.1. The Scheduled Task Wizard's program selection page.


3.

Click Next, and choose how often you want the program to run (see Figure 27.2). Click Next again, and then specify applicable time options, such as time of day, as required.

Figure 27.2. The Scheduled Task Wizard's execution schedule page.


4.

Click Next, and you are prompted to enter the user's name and password so that the task can be executed as though the user (typically, you) were there to run it. (It may already be entered for you, using the current user's name, preceded by the computer name.) After a username and password are set, another user cannot cancel or delete the task unless that user has the correct permissions. If you are working with a user account without a password, don't type in anything in the password field.

NOTE

The computer name is technically necessary only if you are on a network but want to run the task with local authentication. I cannot think of any reason to do so, unless your domain account doesn't have the correct local rights.

5.

Click Next. If you want to set advanced options such as idle time, what to do if the computer is running on batteries, and what to do after the task completes, mark Open Advanced Properties for This Task When I Click Finish.

6.

Click Finish to close the wizard. The task is then added to the list and will execute at the preassigned time.

If you chose to open the task's advanced properties upon clicking Finish, its dialog box now opens. To open this same dialog box manually, open the Scheduled Tasks applet, right-click the task in question, and choose Properties. The three tabs on this dialog box enable you to modify it as follows:

  • From the Task tab on the Properties dialog, you can disable the task temporarily, without having to delete it, by clearing the Enabled check box. As of SP2, there is a new check box on the Task tab of the advanced properties dialog: Run Only If Logged On. If you don't want this task to run unless you have logged in to the computer, check this box.

  • Use the Schedule tab to change the task's timing. You can change the scheduled time using the options present, or use the Advanced button to access more advanced scheduling options. There is also a check box that allows you to enable multiple schedules for the task.

When you're finished, click OK to save any changes made to the properties sheet. Now that you've established a task, though, there are still more issues to consider.

If you want to remove a task from the Scheduled Tasks list, right-click it, and choose Delete. Choosing Delete here doesn't remove the executed application from your hard disk, it just removes the task from the list of tasks to be executed.

To use controls that affect all tasks in the Scheduled Tasks applet, use the commands on the Advanced menu from the main Scheduled Tasks window's menu bar. You'll see a number of useful items there, as shown in Table 27.2.

Table 27.2. Advanced Settings for the Scheduled Tasks

Option

Description

Stop Using Scheduled Tasks

This option turns off the scheduler, preventing it from running any added tasks. The scheduler won't start automatically the next time you start Windows XP. To reactivate it, you have to open the Scheduled Tasks and choose Start Usin Scheduled Tasks.

Pause Scheduled Tasks

This option temporarily suspends added tasks in the task list. This capability is useful if you are running a program whose operation could be slowed down or otherwise influenced by a scheduled task. To resume the schedules for all tasks, choose Advanced, Continue Scheduled Tasks. If a task's execution time is now past, it will run at the next scheduled time.

Notify Me of Missed Tasks

If a task can't complete for some reason, a dialog box pops up, letting you know what was missed. For example, if the computer was turned off when a task should have been run, you'll be told of this situation when you boot up next.

AT Service Account

The Scheduled Tasks runs any commands scheduled using the at command-line utility, which is a carryover from Windows NT. By design, commands scheduled by at all run under the same login account. This option lets you specify which account is to be used. You can leave it set to the default LocalSystem setting, or you can turn on This Account to specify a user account.

View Log

This option brings up a text file in Notepad, listing tasks completed, date, and other information about the tasks. Note that some tasks listed in the log might not appear in the Scheduled Tasks list. This omission can result from system tasks initiated by other services such as synchronization (such as Web page subscriptions and offlin folders). For coverage of these issues, see Chapter 9, "Browsing the World Wide Web with Internet Explorer," and Chapter 18, "Windows Unplugged: Remote and Mobile Networking."


TIP

You can run one of your tasks immediately by right-clicking the task in question and choosing Run. You also can reach Scheduled Tasks tasks through the Explorer by going to the \windows\tasks folder.


If the Scheduled Tasks fails to activate properly, see "The Scheduled Tasks Doesn't Activate Correctly" in the "Troubleshooting" section at the end of this chapter.



TIP

After installing SP2, some users have complained that the only way they could get Scheduled Tasks working again was to open each individual scheduled task, then uncheck Only If Logged On. Then choose OK or Apply. Then they had to recheck Run Only If Logged On. You must do this with each and every scheduled task listed to get them all to work again.


You can view scheduled tasks on a remote computer by opening My Network Places, opening the computer in question, and then opening the Scheduled Tasks folder. You need administrative privileges if you want to view the settings on a remote machine. If you want to edit remote settings, the requirements are greater; you can edit tasks on a remote computer running Windows 95 or later, Windows NT 4.0, Windows 2000, or Windows XP only if that remote computer has remote Registry software installed and shares the x$ share, where x is the hard disk on which the Scheduled Tasks folder resides. That is, it must be shared with an "Administrative Share."

Unlike under Windows 2000, Windows XP tasks do not have task-level ACLs. However, if the user account defined as the "run as" account does not have access to the executable, the task will not be able to run.

NOTE

If you are familiar with the old at command-line utility from Windows NT, you'll be happy to know that it still works in Windows XP. Commands scheduled with at appear in the Scheduled Tasks's list, as well as the list of commands that at displays. It's one and the same list. However, if you modify the command within Scheduled Tasks, it will no longer appear in the list displayed by at. at is the command-line tool used to schedule tasks on a Windows NT system. The at command is still supported by Windows XP (as it was under Windows 2000). You can see the correct syntax for this command-line tool by entering at ? at a command prompt. at stands for "at time" and was originally found on Unix systems. AT commands will only for 72 hours.




Special Edition Using Microsoft Windows XP Professional
Special Edition Using Microsoft Windows XP Professional (3rd Edition)
ISBN: 0789732807
EAN: 2147483647
Year: 2003
Pages: 450

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net