How to: Automatically Defragment Drives Other Than C: on Separate Schedules

| | Comments (1)

When Vista is set up, the disk defragmentation task is set to automatically defrag all the drives in the system.  This isn't a bad thing, but what if you want to get a little more control over the defrag process -- for instance, defrag one drive at full speed on one day, and defrag another drive in idle speed on another day?

In this little tutorial I'll show you exactly how to do that in Vista, which will also serve as a quick primer in how to create a scheduled task in Vista.  The process of creating a scheduled task is a little different than it used to be, but there are that many more options that can be set because of this.

1. Open the Control Panel and go to Administrative Tools | Task Scheduler, and then click on that to open it (UAC).

2. Expand the tree of tasks in the left-hand pane: Task Scheduler Library | Microsoft | Windows | Defrag, and click on the Defrag folder.

3. Click on Create Task in the Actions panel.  Note that there's also a Create Basic Task command, but the Basic Task wizard doesn't have all the options we need (such as running a job as administrator).

5. Under Name and Description, type a suitable description -- for instance, if this is being used to defrag drive D:, the name would be Defrag D and the description would be Defragments drive D: periodically.

6. Enable the options Run whether user is logged on or not and Run with highest privileges.

7. Click on the Triggers tab and click New to add a new trigger for this event (i.e., what starts it up).  In the Begin the task: dropdown, select On a schedule, and set the schedule to Weekly.  Pick one day of the week to run the defrag on (I prefer Wednesday), and also set the time that you want the job to start.

The rest of the options can be left alone, so Click OK to add the trigger.

8. Select the Actions tab and click New.  From the Action: drop-down, select Start a program; under Program/script, simply type defrag.  Under Add arguments, type d: (i.e., the drive letter).

Note: If you want this drive to be defragmented in idle mode, add the -i switch.  This is the default option for the regular defrag task, but if you're defragmenting a secondary drive, you can try leaving off the -i and let it run full speed to see what happens.  Idle defrag may take a long time to complete if it runs when you're actually at the controls.

Click OK to add the action.

9. Click OK again to create the task.  You'll be prompted for an admin user account password when this happens; the password is stored with the scheduled task (in an encrypted form).

10. If you want to run the job on demand in the Task Scheduler, right-click on it and select Run.  Otherwise the job will run on the time and day you selected.

That's all there is to it!  Obviously, you can create as many such jobs as you need; be sure not to let multiple automatic defrag jobs overlap each other.

Note that if you want to disable the existing defrag job, you can do so by right-clicking on the job named ScheduledDefrag and selecting Disable.

One final caveat: The defrag jobs will be running as an admin user, so they won't be visible in the Task Manager unless you enable the Show processes from all users option.

1 Comments

thanks. BTW, do you know if the wake the computer to run this task option under conditions work? I remember reading on another forum microsoft is still searching for a fix for that.

[If you could provide me with a link to the forum discussion I'd be most grateful! -- ed.]

Leave a comment