Windows 2000 includes Task Scheduler, a new graphical tool that you can use to run scripts or programs according to a schedule. The tool helps you create and customize scheduled tasks, then saves the tasks as .job files, which reside in \%systemroot%. You can schedule tasks to run locally, or you can email or copy .job files to remote computers to run scheduled tasks on those computers. Although Task Scheduler doesn't completely replace the At command, which you might be familiar with from Windows NT, Task Scheduler does offer a simpler, more efficient way to schedule tasks. Task Scheduler's advantages over the At command include easier administration, more configuration options (e.g., options to schedule tasks during logon, system startup, or idle time), and the ability to run tasks in different security contexts. (For information about the interaction of Task Scheduler and the At command, see the sidebar "What About the At Command?")
Launching Task Scheduler
Before you run Task Scheduler, be sure the computer's date and time settings are correct. To launch the utility, use the Control Panel Scheduled Tasks applet, or click Start, Programs, Accessories, System Tools, Scheduled Tasks, then double-click the Scheduled Tasks icon. The Scheduled Tasks window opens to display an Add Scheduled Task icon, as well as icons for any existing tasks. You can choose among three methods for creating a new task: Use the Scheduled Task Wizard; manually configure the task; or drag a program, script, or document into the Scheduled Tasks window.
Using the Scheduled Task Wizard
To launch the Scheduled Task Wizard, double-click the Add Scheduled Task icon. Click Next to move past the opening screen. The wizard presents a list of the application files on your computer; this list includes applications that you installed with the OS as well as any third-party software that appears in the Control Panel Add/Remove Programs applet. If the application you want to schedule isn't on the list, click Browse to open the Select Program to Schedule window. You can then select a local application or script, or you can browse through the network to select an object on a remote computer. After you select an object, click Next.
The next screen, which Figure 1 shows, prompts you to name the task and specify when you want it to run. The subsequent screen prompts you to enter a start time and other options specific to the task's frequency. (If you selected the When I log on or When my computer starts option, the wizard skips this screen.)
The next screen prompts you to enter a username and password; the task will run as if started by that user. The final screen offers the usual Finish button but also includes an option to automatically open the created task's Properties dialog box when you click Finish.
Manually Creating a Scheduled Task
After you're familiar with Task Scheduler, manually creating a task is often faster than using the wizard. The manual process also lets you move among settings to fine-tune the task. Instead of stepping through the wizard, you can manually create a task, then leap directly to the task's Properties dialog box to configure the task. This manual procedure also applies to dragging an application or script into the Scheduled Tasks window; the only difference is that dragging the application or script into the window creates the new scheduled task.
To create a task, open the Scheduled Tasks window, then click File, New, Scheduled Task. (You can also right-click a blank spot in the Scheduled Tasks window and choose New, Scheduled Task.) A New Task icon appears. The title is in Edit mode so that you can immediately enter a name for the new task. Right-click the task icon, and click Properties to open the task's Properties dialog box. The Properties dialog box contains four tabs, which offer several options for manually configuring the task.
The Task tab. On the Task tab, which Figure 2 shows, enter the name and path of the application you want to run. If any part of the path contains spaces, enclose the entire path in quotation marks. If the scheduled task is an executable file, you can add parameters you want to run with the program. Next, enter the user under which the task will run. You can also disable the task from this tab; to do so, clear the Enabled (scheduled task runs at specified time) check box.
The Schedule tab. On the Schedule tab, specify the task's frequency. Note that a difference exists between the options on this tab and those in the wizard. When you choose to run a task Daily, the wizard offers a Weekdays option; the Properties dialog box doesn't. If you want to run a manually configured task only on weekdays, you must select Weekly on the Schedule tab, then select individual days. To fine-tune the schedule, click Advanced; the advanced options differ depending on the schedule frequency (e.g., Daily, Weekly) that you choose.
The Settings tab. The Settings tab, which Figure 3 shows, offers options to control task operation under certain system conditions. Under Scheduled Task Completed, you can select the Delete the task if it is not scheduled to run again check box for tasks that have an end date or that run only once. When you select this option, Task Scheduler removes the job after the last automatic occurrence. Don't select this option if you might reincarnate the task. The Stop the task if it runs for option lets you end the task after a specified time (the default is 72 hours). This option is useful for time-consuming middle-of-the-night operations that must finish before the business day begins. Because the default allowance is overly generous for most tasks, you should configure the time to suit the operation's needs rather than accept the default.
Under Idle Time, you can specify options for a task that you configured to execute during idle time (i.e., time during which no mouse or keyboard activity occurs on the target system). Of course, no mouse or keyboard activity doesn't mean a computer is idle; all sorts of activities could be happening, including downloads, database searches, or other automated tasks. Keep this caveat in mind when you schedule tasks: You probably don't want several I/O- or processor-intensive tasks running at the same time unless you're prepared to let them run longer than they typically would individually. The Idle Time options don't necessarily make scheduled tasks run more efficiently.
Under Power Management, you can specify a task's behavior if battery-power problems arise when the task is scheduled to run or is already running. This option applies to laptops rather than computers that switch over to a UPS during electrical power loss. (UPS software such as American Power Conversion's—APC's—PowerChute usually configures all programs, including automated tasks, for shutdown in such an event.) An option to Wake the computer to run this task appears for computers that support that feature.
The Security tab. On the Security tab, which Figure 4 shows, you can specify the users who can view, delete, modify, or use a task. (Table 1, page 102, describes the available permission levels.) Task Scheduler bases task security on standard Win2K security permissions. Remember that the program, script, or document that the task runs might also have security restrictions if the target computer runs NTFS. Be careful not to create a conflict between these security levels.
To configure advanced security options for the task, click Advanced. The Access Control Settings dialog box, which Figure 5 shows, presents options for granular control over permissions, auditing, and ownership.
Working with Scheduled Tasks
After you create and configure a task, you might want to modify it or check its status. Task Scheduler offers several options for working with existing tasks.
Start and stop scheduled tasks. You can run any task at any time rather than wait for the next scheduled occurrence. To start a task, open the Scheduled Tasks window, select the task, and choose File, Run from the menu bar. (You can also right-click the task, then click Run.) To stop a running task, right-click the task, then click End Task. The message might take a moment to reach the task.
Check the status of scheduled tasks. To obtain information about a task's status, select the Details view of the Scheduled Tasks window. Figure 6 shows this view; Table 2, page 104, explains the notations that can appear in the view's Status column. You can also check the log file to see detailed information about tasks' performance. To access the log file, open the Scheduled Tasks window and choose Advanced, View Log from the menu bar. You can also open the log manually from Notepad. The log file is \%systemroot%\schedlgu.txt.
Modify scheduled tasks. To change properties for an existing task, open the Scheduled Tasks window, and select the task. Then, open the task's Properties dialog box and make the needed changes.
Delete scheduled tasks. To delete a scheduled task, open the Scheduled Tasks window and select the task. Then, press the Del key, click the Delete icon on the toolbar, or choose File, Delete from the menu bar. (You can also right-click the task and select Delete from the shortcut menu.) Task Scheduler sends deleted tasks to the Recycle Bin. If you don't want a task to run but think you might want to use the task later, disable the task instead of deleting it.
Setting Global Options
Task Scheduler's Advanced menu offers options for manipulating the way scheduled tasks operate. To access this menu, open the Scheduled Tasks window and click Advanced from the menu bar. Then, choose from the following options.
Stop Using Task Scheduler. Select Stop Using Task Scheduler to disable all scheduled tasks and prevent Task Scheduler from running automatically when you start Win2K. To return Task Scheduler to normal operation, select Start Using Task Scheduler.
Pause Task Scheduler. Select Pause Task Scheduler to temporarily halt running tasks and to prevent scheduled tasks from starting. This command is useful for stopping tasks while you install software. To resume scheduled tasks, select Continue Task Scheduler. Any tasks scheduled to run while Pause Task Scheduler was active will run at the next scheduled time.
Notify Me of Missed Tasks. Contrary to its name, the Notify Me of Missed Tasks option notifies you only of Task Scheduler's failure, not of individual missed tasks. Tasks that fail to run because of corrupt or missing executables don't kick off a notification.
AT Service Account. Select AT Service Account to change the user account under which tasks scheduled with the At command will run. (The default account is System.) Selecting this option opens the AT Service Account Configuration dialog box. To change the account, select This Account, enter a user account, and enter and confirm the password for that account.
View Log. Select View Log to open the task log in Notepad. You can then use the log to track the success or failure of your scheduled tasks.
Working with Remote Computers
If you have the appropriate permissions, you can delete or modify jobs on a remote computer. Even if you don't have permission to access tasks on another computer, you can send tasks to someone who does have those permissions.
Viewing and modifying remote tasks. When you work with tasks on remote computers, you need to understand the difference between the remote computer's Scheduled Tasks folder and the Tasks folder in the remote computer's \%systemroot% folder. The Scheduled Tasks folder can be misleading.
When you view a remote computer in My Network Places, Windows Explorer, or My Computer (by using the Folders view), you'll see a folder named Scheduled Tasks. If you select that folder, the contents will look familiar because you're actually looking at the contents of your local machine's \%systemroot%tasks folder. If you delete a job from the remote computer's Scheduled Tasks folder, you're actually deleting it from your computer's Tasks folder. The system won't let you drag jobs between your Tasks folder and the phantom remote Scheduled Tasks folder because you can't drag a job to itself.
To view another computer's Tasks folder, you must expand the remote computer's \%systemroot% folder and select Tasks. Use the Details view to get the most information. The \%systemroot%tasks folder can't be shared, so to access the remote Tasks folder, you must have access permissions either on the \%systemroot% folder or on the drive.
When you can access the target computer's Tasks folder, you can drag or copy a task from your computer to the remote machine. The quickest method is to right-click then drag the task from your local Tasks folder to the remote Tasks folder. (If you left-click and drag, you'll move the job instead of copy it.) Choose Copy Here from the menu that appears when you release the right mouse button. Alternatively, you can use the Copy and Paste commands to copy jobs between folders.
If you can't access the remote computer's Tasks folder, you can place the job outside the \%systemroot% folder on the target computer. Then, you can let that machine's user move the file into the Tasks folder.
Using email to send and receive tasks. You can email a task file (i.e., taskname.job) as a standard email attachment. The recipient can then drag or copy the file to the target computer's Tasks folder.
The file on which the job depends (e.g., an executable or document file) must exist on the target computer. You might also need to adjust the job's properties to reflect the application file's path on the remote computer.
Getting on Schedule
Win2K's Task Scheduler provides a quick and efficient way to automate routine tasks. The tool's ability to save these tasks as files in \%systemroot% gives you plenty of options (e.g., run the tasks locally, email the tasks to remote computers).
Task Scheduler doesn't replace the At command; rather, the new tool builds on the At command's functionality and simplifies task scheduling. (To learn more about the At command in NT, see Mark Minasi, Inside Out, "Where It's AT," March 1998.)
Take advantage of this new tool's extensive configuration options. Then you can watch your scheduled tasks run like clockwork.