Home » Questions » Computers [ Ask a new question ]

Windows XP scheduled tasks and defragmenting?

Windows XP scheduled tasks and defragmenting?

I am trying to set a seduled task to defrag my HDD on a regular basis and following the guide on http://www.microsoft.com/windowsxp/using/setup/learnmore/tips/gehrke1.mspx. It does not work. That process only brings a DOS window which does nothing (well it displays some text about the Microsoft defragging program).

Asked by: Guest | Views: 270
Total answers/comments: 2
Guest [Entry]

"dfrg.msc vs defrag.exe

dfrg.msc is the GUI frontend to the defrag.exe backend tool. What you're essentially doing is invoking the wrong thing, since only defrag.exe takes command line arguments.

Solution

Just use the following for the command path:

defrag C: -f

You shouldn't need to specify any paths, since by default, Windows will search for the tool via the PATH environment variable. The -f switch forces defrag to defragment the specified volume, regardless of how fragmented it actually is (the Windows disk defragmenter sometimes doesn't want to run if the fragmentation level is below a certain threshold).

Why

What you're doing is launching the control panel version, when for a scheduled task, you only want to launch the command-line tool (which is the backend to the GUI).

If you type the following when you go to Start -> Run:

dfrg.msc C:

You will see that it only launches the GUI, which is not what you want. That's why you need to replace dfrg.msc with defrag, and the -f switch forces it to defragment even if the tool thinks that it is ""unnecessary"".

Final note

There's nothing wrong with using the built-in defragmenter, although I would recommend some third-party utilities, which often have the ability to defragment certain files on bootup, automatically prevent MFT fragments, and intelligently order certain files on the disc (to make it quicker to retrieve those files).

Again, this is just something to keep in mind - there is nothing wrong with the built in defragmenter. There are only limitations with it if you are running Windows 2000 or earlier."
Guest [Entry]

Your best bet is just to download a defrag tool that does scheduling, I'd recommend smartdefrag http://download.cnet.com/Smart-Defrag/3000-2094_4-10759533.html