March 1999

Automating System Maintenance with Task Scheduler

Maintaining all your computers and keeping them running at peak performance takes a lot of time--a rare commodity when you're a systems administrator. So, wouldn't it be nice if you could schedule system maintenance tasks just once and then let them take care of themselves? You can--if you're using the Task Scheduler tool shown in Figure A. Task Scheduler allows you to schedule programs to run at a designated time based on specific criteria. These programs can be disk maintenance utilities or any other programs that you need to run on a regular basis.

Figure A: Use Task Scheduler to automate regular system maintenance.

[ Figure A ]

Task Scheduler is a great resource for simplifying and expediting those tasks that seem to monopolize your precious time. In this article, we'll show you just what it can do and how to take advantage of those features.

System Agent or Task Scheduler?

If you're wondering what happened to System Agent, you're not alone. System Agent was the predecessor to Task Scheduler. System Agent is a task-scheduling tool that comes with the Windows 95 Plus! Pack. However, if you install Internet Explorer 4.0, or upgrade to Windows 98, your System Agent tool is automatically upgraded to Task Scheduler. Don't worry, though; all your scheduled tasks will be converted to Task Scheduler tasks. If you're using Windows 95 but don't have System Agent installed, you can install Task Scheduler through Internet Explorer 4.0. To install Task Scheduler, launch Internet Explorer and select Product Updates from the Help menu. Click Yes to allow Windows Update's Active Setup to determine what Internet components are installed on your computer. Scroll down through the list of components until you see the Additional Explorer Enhancements section. Now, select the Task Scheduler check box and then click Next. Select a download site from the dropdown list box and click Install Now to have Active Setup begin installing Task Scheduler. Click Yes to restart your computer when prompted.

Getting to know Task Scheduler

Let's take a quick tour of Task Scheduler and then look at how to schedule a new program. If you're a Windows 98 user, the Task Scheduler is automatically installed and loaded when you install Windows 98. Therefore, you can open the Scheduled Tasks dialog box, shown in Figure A, by double-clicking on the agent's icon in the system tray on the taskbar. If you've just installed Task Scheduler on your Windows 95 computer through IE 4.0, you can launch the Scheduled Tasks dialog box by clicking Start and selecting Programs/Accessories/System Tools/Scheduled Tasks. Then, select Start Using Task Scheduler from the Advanced menu to get the icon on the taskbar. As Figure A shows, no tasks are currently scheduled. As you begin to schedule tasks, they will be listed in the Scheduled Tasks dialog box, along with information on their scheduled run times and the last time they were run. If you'd like to be notified when a scheduled task didn't run, you can select the Notify Me Of Missed Tasks option on the Advanced menu.

Scheduling a task

We'll begin by showing you how to schedule the Backup batch file that you created with the February 1999 issue's "Automating local backups with batch files" article, so that it automatically starts at the same time every day. To begin adding the batch file to the list of scheduled tasks, double-click on the Add Scheduled Task icon to launch the Scheduled Task Wizard. Click Next and then click the Browse button to locate the Backup batch file, which should be in the Desktop folder. Select the Backup.bat file and click Open. Choose the Perform This Task Daily option and then click Next. Now, in the Start Time spin box, shown in Figure B, enter the time that you'd like to have the backup begin--preferably a time when you won't be using your computer. Also, select the date you'd like to begin scheduling the backup in the Start Date dropdown list box and click Next. Finally, click Finish to get back to the Scheduled Tasks dialog box. Your Backup batch file will now run every day at the time you specified.

Figure B: You can specify what time and date you'd like the scheduled task to begin.

[ Figure B ]

Modifying the task

If you later decide that the schedule you've set for the backup isn't going to work, you can easily modify it to better suit your needs. To do so, simply double-click on the backup task in the Scheduled Tasks dialog box and click on the Schedule tab. The Schedule tab is used to determine the frequency, day, and time that the task will be run. As Figure C shows, you can change the schedule to run the backup every week on Mondays, Wednesdays, and Fridays at 5:30 p.m. instead of daily at 5:00 p.m.

Figure C: Once you schedule a task, you can modify the schedule as needed.

[ Figure C ]

If you click on the Settings tab, as shown in Figure D, you can also configure how the task should run if the computer is idle. It may be a good idea to select the Only Start The Scheduled Task If Computer Is Idle For check box and specify the time in minutes using the up or down arrows in the spin box. Then, if the computer isn't idle when the task is scheduled to start, you can set it to retry for a designated period of time.

Figure D: The Settings tab allows you to further customize the task's schedule.

[ Figure D ]

Why not automate ScanDisk, too?

Task Scheduler is a great tool, not only for automating your local backup, but also for running disk maintenance utilities, such as ScanDisk. As Figure E shows, you can use Task Scheduler to schedule both a Thorough and Standard ScanDisk to be run on different schedules. Since a Thorough ScanDisk doesn't need to be run as frequently, we have it scheduled to run only once a month, at the beginning of the month.

Figure E: You can use Task Scheduler to schedule both a Thorough and Standard ScanDisk.

[ Figure E ]

You can set ScanDisk to be Thorough or Standard after adding the task through the Scheduled Task Wizard. When you're naming the tasks, just make sure that you designate which one is Standard and which one is Thorough. Then, once ScanDisk appears in the list of Scheduled Tasks, double-click on it to open the ScanDisk properties sheet shown in Figure F. Click the Settings button on the Task tab to open the Scheduled Settings For ScanDisk dialog box. In the Type Of Test panel, you can select either the Standard or Thorough option. Then, click OK twice to return to the Scheduled Tasks dialog box.

Figure F: Some of the disk utilities will have a Settings button on the Task tab.

[ Figure F ]

Behind the scenes

Once you create a scheduled task, it's stored in the \Windows\Tasks folder as a JOB file. Therefore, after creating a scheduled task on one workstation, you can share it with other workstations by copying and pasting it to each machine. A little bit of time spent up front could save you a lot of time down the road.

Conclusion

Task Scheduler is a great tool for running system maintenance tasks without interfering with your work. It's also just the trick for scheduling almost any other task you want to run when you're not going to be around. In this article, we showed you how to schedule your local backup using a batch file, and that it's also possible to schedule a backup job that was created in Microsoft Backup. Next month, we'll take this series on backups in another direction by showing you how to backup your hard disk(s) using a backup agent.

Copyright © 1999, ZD Inc. All rights reserved. ZD Journals and the ZD Journals logo are trademarks of ZD Inc. Reproduction in whole or in part in any form or medium without express written permission of ZD Inc. is prohibited. All other product names and logos are trademarks or registered trademarks of their respective owners.