This is a common problem with Windows's built-in defragmenter, especially in Windows 9x and Me. Because it's sensitive to any changes in the system state, it often winds up getting stuck in an infinite loop. One way to get around this is to have Defrag run at the next reboot before the user interface finishes loading.
To do this, copy the following into a text file and save it with the filename DEFRAG.REG (make sure you have file extension display turned on in Explorer to do this correctly). Double-click on it to enter it into the Registry, then reboot. The next time your system loads, it should run a full defrag pass without stopping.
This was first published in May 2004