How to run Defrag on a scheduled basis

On Windows XP, it’s simple. Just run this command and you are done:

schtasks /create /TN defrag /RU “NT AUTHORITY\SYSTEM” /SC weekly /TR “defrag %systemdrive%”

Comments (5)

  1. custard555 says:

    Is it the same for Win 2003 ?



  2. AdiOltean says:

    The same command should work on Windows Server 2003 as well.

  3. Skywing says:

    I have to say that I’ve not exactly been alltogether impressed by defrag.exe.

    In my experience, at least for systems where you can afford planned downtime, the best way to really defrag a partition is to back the whole thing up, wipe the partition, then restore it (a-la ntbackup).  Of course, defrag bogs down the system enough that you pretty much need to schedule downtime anyway.

    Naturally, this is easier to do if you properly separate the partition the OS is installed on from the partition you have other programs or data on.

  4. Castor Fu says:

    Thank goodness that Windows has displaced the user-unfriendly Unix with

    its obscure commands and single letter flags 🙂  Now we have two letter flags; twice as good!

  5. This isn’t that big of a deal, but since some articles make it sound like this is a difficult thing,…