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.
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).
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:
You will see that it only launches the GUI, which is not what you want. That's why you need to replace
defrag, and the
-f switch forces it to defragment even if the tool thinks that it is "unnecessary".
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.