To access the defragmentation program in Windows XP, click the Start button and go to Programs -- Accessories -- System Tools. Find the Disk Defragmenter tool, and click Analyze to determine if the computer needs defragmenting. If it does, shut down all running applications, and click Defragment Disk.

To start the defragmenting process in Windows 7, click the Start button, then search Programs. In Windows 8, open the Charms, and type Defragment disk in the Search bar.

Once the defragmenting process starts, check to ensure that the computer is plugged into an electrical source. Defragmenting often takes between 30 minutes and several hours, depending on the fragmentation level, the capacity of the hard drive, the available operating memory and the processor speed. If the computer shuts down during the process, it may harm the hard drive.

If you want to schedule regular defragmentation to ensure optimal computer performance, click on Configure Schedule, and choose the frequency, day and time that you want the program to run. A computer works best if fragmentation is below 10 percent. For people who use their computers daily, monthly defragmenting is typically enough to maintain this level. However, heavy users should defragment their computers daily or weekly, according to TechTerms.

Mac computers do not have a preinstalled defragmenting tool. However, Mac users can install a defragmenting utility, such as DiskWarrior or Tech Tool Pro, if they want to defragment their disks.