I finally figured out how to do it! In the attached zipfile you will find 6 files: dirms.exe - the defragmentation tool dirms.bat - batchfile to call dirms.exe with switches pgdfgsvc.exe - pagedefrag optimize.reg - registryentries needed for chkdsk,pagedefrag and dirms optimize2.reg - restores the userinit-section optimize.cmd - batchfile to start the optimization-proces This is what optimize.cmd does: 1.merge optimize.reg into the registry, these items will be added to the bootexecute-section: -chkdsk /F /R (=check C: for errors, repair them and check free space) -pgdfgsvc -o (=defrags only at next boot) 1b.this will be added to the userinit-section: -dirms.bat, userinit.exe (=needed to load your shell,DON'T remove it!!) (dirms.bat runs dirms.exe c DEFRAG COMPACT) 2.Restarts your computer after 30 seconds, giving you time to save your work Once the whole proces has finished, XP will be started. Put all files except optimize.cmd in C:\WINDOWS\system32\ Put optimize.cmd on your Desktop or whereever you want.. NOTE: I only added support for C: Links to the used programs: Dirms: http://www.dirms.com/ Pagedefrag: http://www.sysinternals.com/ntw2k/freeware/pagedefrag.shtml Chkdsk: already installed with XP I hope someone finds this as usefull as I do EDIT: Now it should work. Optimize.zip