How to automate Windows Server 2003 defrag

Learn how to set up Windows Server 2003's DEFRAG command-line tool so it runs without the need for manual administrative maintenance.

Related Windows defragmentation and command-line resources

Top 10 Windows Server 2003 command-line functions.

Script to defrag all Windows volumes.

Microsoft Windows Server 2003's DEFRAG command-line tool can be configured to run automatically without the need for manual administrative maintenance.

Setting up Windows Server 2003 DEFRAG to run automatically is relatively simple:

1. Go to Control Panel -> Scheduled Tasks -> Add Scheduled Task to open the Scheduled Task Wizard and then click Next.

2. Hit the Browse button, search for the %SystemRoot%\system32\defrag.exe file and run it.

 

3. Choose a name and schedule and then click Next. A heavily trafficked Windows 2003 server will probably benefit from daily defragmentation; a less-trafficked server can be defragmented weekly.

4. Choose a start time -- ideally when the server load will be slow.

5. Enter the username and password for a local administrator account. DEFRAG must run under the auspices of an administrator account that has the right to manage local disks. But this does not necessarily have to be a full administrator account. You can set up a specially created local account that only has disk-management privileges if you want.

 

6. Click Next and select "Open Advanced Properties…" and click Next again.

7. Under the Tasks tab, there are a few options that can be set. If you want to modify the DEFRAG command-line parameters, you can do so here. Generally, DEFRAG needs no parameters to run properly. The only exception is the –f switch, which forces DEFRAG to run when there is little free space. But DEFRAG shouldn't need to be run with the –f switch as a scheduled job.

8. Click OK to approve the job.

Windows Server 2003 is now configured to automatically run the DEFRAG command-line tool based on the schedule you specified.

A free third-party tool I've used as a capable substitute for Windows Server 2003 DEFRAG is JKDefrag. It is available in a command-line/scriptable edition and uses the same defrag APIs as the Windows Server 2003 DEFRAG tool, but with many more options. If you use JKDefrag, read the documentation thoroughly -- not all the command-line switches are suitable (or even needed) for a Windows Server environment.

About the author: Serdar Yegulalp is editor of Windows Insight (formerly the Windows Power Users Newsletter), a blog site devoted to hints, tips, tricks and news for users and administrators of Windows NT, Windows 2000, Windows XP, Windows Server 2003 and Vista. He has more than 12 years of experience working with Windows, and contributes regularly to SearchWinComputing.com and other TechTarget sites.

This was first published in September 2007

Dig deeper on Microsoft Active Directory Security

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close