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:
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:
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.
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.
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. |