Problem solve Get help with specific problems with your technologies, process and projects.

Automating disk defragmentation

After you install applications on a server, running Disk Defragmenter on a regular basis will ensure they run efficiently. You can put an end to disk defragmentation as a manual process by scheduling it via the Windows Task Scheduler.

After you install a lot of applications on a server, systems administrators should run Disk Defragmenter on a regular...

basis so they can run efficiently. However, that may be difficult to do on timely basis because of your busy schedule.

Today, it's possible to put an end to disk defragmentation as a manual process by scheduling disk defragmentation via the Windows Task Scheduler. Windows XP and Windows Server 2003 both include a new way to invoke the Windows Defragmentation tool via the command line. (In prior versions of Windows, there was no way to invoke this tool with the Command Line.)

Here is an example of the usage of defrag.exe:

defrag.exe -v d: >c:templogfile.txt

This command will begin the Defragmentation of the target machines D: drive.

The v switch enables verbose logging of the location specified at the end of the command. Now you can create a batch file using the above command without manually performing the task of disk defragmentation.

Please let us know how useful you find this tip by rating it below! If you have a useful Windows tip, timesaver or workaround to share, submit it to our tip contest and you could win a prize!

This was last published in August 2006

Dig Deeper on Windows systems and network management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.