Tech

Guides
 

Defragment your Windows Server 2003 hard drive on a set schedule

By Derek Schauland , Special to ZDNet Asia
Tuesday, October 02, 2007 09:38 AM
You can defragment the hard drives on your Windows Server 2003 boxes on a set schedule by simply creating a batch file to defragment a drive and setting up a scheduled task to execute it.
You can defragment the hard drives on your Windows Server 2003 boxes on a set schedule by simply creating a batch file to defragment a drive and setting up a scheduled task to execute it.

Creating a .bat file
To create this little piece of code, open a new file in your favorite text editor, such as Notepad. You will also need to open the Windows command shell (cmd.exe). The command shell will help you nail the syntax of the operation so there are as few hiccups as possible.

  1. In the command prompt window, enter the following:
    C:> defrag.exe /?
    The help documentation will display for defrag.exe, showing the syntax you need to run the application and any optional switches.
  2. To keep it simple and to restrict the defrag operation to one drive, you can enter the syntax for our batch file into the text editor as follows:
    Defrag.exe c: -f
  3. Save the text file with a name and the .bat file extension.
  4. You will also select all files in the file types drop down.

Scheduling the execution of fragments
To schedule the batch file to run, we can run an AT command from the command prompt. AT commands add Scheduled Tasks without going through the GUI-based application; this can speed up the creation of scheduled tasks.

In the command prompt window, press [Enter] a few times to get a C:\> prompt within view. Enter the following to see the syntax and examples of the AT command:

AT 02:30am /every:M,T,W,Th,F c:\defragment.bat

Note: Walking through the entire process will help to familiarize you with all of the available options for commands used in this tip. The help display is for demonstration purposes only; you do not need to perform it.

Press [Enter] after entering the command, and a scheduled defragmentation of the local C: drive will take place weekdays at 2:30 in the morning.

You can verify the task by visiting the Scheduled Tasks folder in the Accessories folder of the Start menu.



WORTHWHILE?

0

0 votes
Blog

Talkback 0 comments

There are currently no comments for this post.


Guest user

Guest user

Level: 
Joined: —
Already a member? Log in »



 

Loading...

Whitepapers/Case Studies

Downloads

Windows Server News



Tech Jobs Now!

Tags

  1. domain controller
  2. environment
  3. group policy
  4. hardware
  5. infrastructure / architecture management
  6. microsoft server 2003
  7. microsoft windows
  8. microsoft windows active directory
  9. microsoft windows powershell
  10. microsoft windows server
  11. microsoft windows server 2008
  12. network
  13. ohio
  14. rick vanover
  15. server
  16. server platforms
  17. servers
  18. storage
  19. tool
  20. virtualization