On regular use of system, Windows randomly saves data and then randomly deletes them as required. This random access of the storage media and read/ write process fragments the large data files before storing it in the hard drive. Fragmentation slows the read/ write performance of the hard drive because the data is not well organized, and the system needs to assemble the fragments to provide the required data as a complete information.
The optimum speed of data access may be recovered if the hard drive is defragmented on a regular basis. Defragmentation places the fragmented files scattered in distant clusters of the hard drive in the contiguous clusters, hence making it easier for the read/write heads of the hard drive to gather the needed information almost instantaneously.
Speed up defragmentation:
Windows 7 has built-in defragmentation feature which is by default scheduled to be executed every week. However, since the process is set as low priority, it gets interrupted or stops altogether in case any high priority process or application is already running in the background, or is initialized at the time of defragment process.
Therefore, in order to perform the defragmentation process with high priority, a batch file with appropriate parameters can be created executed at the specific times.
As discussed above, running other applications or accessing other files may hamper the defragmentation process. To avoid this, the process is scheduled. This can be done by creating a batch file with specific parameters that set the priority level of the defragmentation process to normal, hence allowing Windows to perform the task without interruptions, and using the Windows Task Scheduler to schedule the execution of the batch file.
Creating a batch file:
- Open Notepad.
- Write command Defrag “C:” /H. (C: drive is to be defragmented using this batch file. Also, /H parameter is used to set defragmentation process priority level to normal.
- Save the file as ‘Defrag.bat’ to make it as batch file. (You can use any name for the file but the extension must be .BAT whatsoever).
- Click the Start button.
- At the bottom of the Start menu, in the search box, type Task Scheduler and hit Enter key.
- On the opened window, from the Actions pane in the right, click Create Basic Task.
- On the window that appears next, provide a name to the task in the Name field.
- In the Description field type a brief description for the task.
- Click Next to continue.
- On the Trigger Task window, click to select the radio button as required. (Daily for this demonstration).
- Click Next to proceed.
- On the next window, specify the date and time when the task should be executed along with the recurring period.
- Click Next to continue.
- On the Action window, click to select Start a program.
- Click Next.
- On the next window, click Browse to locate the ‘Defrag.bat’ file that is to be executed.
- Click Next when done.
- On the Summary window, click Finish to create the task and to execute the batch file as per the scheduled time.