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.