Schedule a Task to Defragment Drives
1. Open Control Panel, and then click Scheduled Tasks.
2. Double click Add Scheduled Task to open the Scheduled Task Wizard, and then click Next.
3. Click Browse, navigate to the %systemroot%\system32 folder, select defrag.exe, and click Open.
the wizard to set a schedule for when to run the defragmentation
program, and be sure to supply a password for the account on
which you want the task to run.
5. Check the box for Open advanced properties for this task when I click Finish.
the Run line, add the drive letter for the drive to be defragged.
For example, %SystemRoot%\System32\Defrag.exe %HomeDrive%