Various approaches to getting Defrag to work are not so hot, you can tell by the discussion. SAFE mode is the best, but of course it trashes your desktop.
Personally I think it is MSTASK that is writing things to C: that is trashing DEFRAG, but any program that periodically writes to the drive being defragged will make idiot defrag restart.
To defragment all your hard drives/partitions with no overhead (background programs running or TSRs/VXDs loaded), change to the \Tools\Mtsutil folder on your Win98 Setup cd-rom, and right-click on Defrag.inf. Select Install.
This will create a one-time entry (DEFRAG.EXE /ALL) under this Registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesOnce
Defrag will start automatically next time you boot, before the login prompt, therefore before any other program loads.
An easy way to package this and without digging up the CD is to make a file, call it DEFRAG.REG, you can snip it...
If you put it anywhere, say C:\stuff\defrag.reg, then the next time you want to defrag you just explorer to it and click-click. Reboot and Defrag will run before a lot of windows mud is loaded and perhaps Defrag will work. Worth a try.