Skip navigation.

Square Wheels

Correct history's mistakes in your daily life

Defragment While You Sleep, Go to Lunch, or Do Anything Else

, , , ...



Defragmenting your computer's hard disk is routine maintenance that should be done every month. Windows' built-in disk defragmenter does the job but uses so much of your CPU's power that doing anything else on your computer while defragging is counter-productive; the defrag slows down whatever else you're working on and that, in turn, creates more work for the defragmenter to do. Downloadable utilities that automate the process are available but, compared to the following method, which uses the already-installed defragmenter, they are simply a waste of disk space —exactly what you are trying to avoid.

Instead, run Disk Defragmenter after Disk Cleanup and turn off your computer all with a simple keystroke combination of your choice. For a hard drive older than a year that's never been defragmented the process takes one to four hours but, done monthly, the time will shorten to about twenty minutes.

To ensure the defrag will not be interrupted by System Standby, Sleep, or Hibernation, in the Power Options of Control Panel choose ‘When I close the lid...’ » Do Nothing, and for Power Schemes, both Plugged In and On Batteries » Always On, and ‘Turn off hard disks’ » Never.

Into a blank Notepad document (keystrokes: Windows+R, notepad, Enter) copy and paste these three lines:

cleanmgr /sagerun:1
defrag c:
shutdown -f -s -t 00

Save (Ctrl+S) in My Documents and name this document clean&defrag.bat and save as type » All Files. The .bat changes this from a simple text file into a batch file in which each line is now a command the computer will execute in order from top to bottom. The first line runs Disk Cleanup without asking which settings you want to use, so to review your settings, in the Command Prompt (Windows+R, cmd, Enter) type cleanmgr /sageset:1 and check the boxes of what you want cleaned up, the more the better. After defragging, the computer will shut down, taking care to properly close any programs that may have been left running.

To make a keyboard shortcut for this whole maintenance process go to My Documents, highlight the clean&defrag.bat icon, press Shift+F10, » Send To... » Desktop (Create Shortcut). Highlight the Desktop icon you just created, press Alt+Enter, look for shortcut tab or ‘shortcut key’ text box, highlight it and press the key combo you want to use, such as Ctrl+Alt+D or Alt+Shift+C. Restart for all the changes to take effect.

Once a month, when you're ready to shut down the computer for the day or going to lunch, press your keyboard shortcut and let your computer handle all that grunt work. ※



UTC