How to ensure defragmentation occurs on Windows 7
By default Windows 7 runs a scheduled task every Wednesday at 1 am that defrags the computer's hard drive. The task is also configured so that defrag only occurs when the system is idle. And if your computer happens to be turned off at 1 am on Wednesday morning, the fact that the "Run task as soon as possible after a schedule start is missed" option is enabled for this task will cause defrag to be run the next time the system is started—provided there's a period of inactivity where the system is idle.
But what if your computer is never idle? Let's say for example that you turn your computer on when you get to work and immediately begin working on it, then at lunchtime you shut the computer down, and similarly in the afternoon. In that case the defrag task may never run. What should you do to ensure your hard drive doesn't become fragmented?
The solution is to open the defrag task from Task Scheduler, select the Conditions tab, and clear the checkbox that specifies that the task should only run when the system is idle. Doing this will cause defrag to run even when the computer is being used. In most cases the performance hit from defrag running in the background should be negligible, but be sure and test this anyways before accepting this configuration change as permanent.