|It's probably not a good idea to run defrag on a 98 system from pure dos. Windows doesn't let defrag move certain files but if you run it from dos that move restriction may not hold and you could end up with a non-working 98 system.|
That said, the 'invalid dos version' can be fixed by adding defrag to setver. For example to add the dos 6.22 version to setver you'd type setver defrag.exe 6.22. Then make sure setver.exe is loading in config.sys. HOWEVER, defrag from pre-windows dos will only run on fat16 partitions. So if 98 is installed on a fat32 partition--which it usually is--those defrag won't run. Also, I'm not sure how defrag from dos will treat long file names even if they're on a fat16 partition. (Early on I kept a 98 installation on a fat16 partition just so I could run some of the old dos utilities. Seems like I did defrag it once and ended up will all the file names shortened to 8.3 format.)
Another option is Norton Disk Doctor (NDD) from Norton Utilities for dos. But as far as I know all those versions were limited to fat16 also.
There must be some third party defragging software that will work with fat32. I googled defrag "fat32" dos and got quite a few hits. Here's one:
There's also this computing.net thread from 2008 where I mentioned there was a defrag program in NTFS4DOS:
Also there may be a version from DR Dos (Digital Research's version of dos) that might be fat32 capable.