Does the command Defrag %SystemDrive% /b really work to optimize Windows boot time? (The defrag /b option is not documented by Microsoft).

I am trying to use it in an attempt to optimize the files on the hard disk that Windows use to boot up the system. I suspect that I need to schedule defrag before Windows boot, however I am not succeeding with it with defrag. Is there other software that works for it?

  • Would be nice to know what operating system, as defrag changed significantly from XP to Windows7, in XP you have to use a Microsoft utility bootvis to optimize boot files, W7 does this natively in its defrag routine. – Moab Feb 22 at 16:04

Defrag is a Windows program and runs while Windows is running. You can schedule a scan disk for before Windows completely loads, but not defrag. There are tools you can use that defragment outside of Windows, but Windows' built-in defrag is more than sufficient for most needs.

I schedule defrag to run for a few hours a couple of nights each week. That way it keeps the disk to a very low level of fragmentation.

Regarding the -b option, I found this explanation: http://www.edbott.com/weblog/2003/04/beware-of-bogus-xp-advice/

The Prefetch directory has one additional salutary function when used in conjunction with the built-in defragmenting tool. Every three days, during idle times, this utility rearranges program code, moving it to the outside of the disk to make it more efficient when loading (to force Windows to perform this optimization without having to do a full defragmentation, use the Defrag.exe command with the -b switch. For instance: defrag c: -b).

Apparently your computer already does this regularly, and unless you move massive files frequently across your hard disk drive and restart several times each day, you're not going to notice must of a benefit.

In my experience, people turn to defrag to speed up their systems much too quickly. I can count on one hand the times defragging has actually sped up systems that I have observed. And as a veteran of corporate and consumer IT support, that's saying something.

Set a scheduled defrag, don't bother with the -b option, and leave it at that. If you have computer slowness there are a myriad other options you should look into that will be much more effective in speeding the system up.

  • 2
    windows 7 has a scheduled defragmentation run by default, iirc – Journeyman Geek May 17 '11 at 5:45
  • As a veteran of corporate and consumer IT support, I can say that while I had my doubts, using a program such as MyDefrag on boot drives does visibly improve boot times. It's just that Microsoft messed up their defrag tool and made it useless, much like everyhting else they ever made. – Jure Sah May 30 '17 at 8:58
  • Then our experiences differ, @JureSah. However, this is a very old question that is more applicable to older versions of Windows and older types of hardware. On modern SSDs, and in Windows 7 and later, there is no reason for the average person to run Defrag, and even with our differing experiences, I believe you'd likely agree that the average person, on the average computer, jumps to the idea of "defrag" as some sort of panacea that is less likely to fix their specific issue than they realize. – music2myear May 30 '17 at 16:08
  • @music2myear keeping disks defragmented is a good common practice that helps maintain performance in the long run, as such for the average person it is a recommended thing to do. I agree it doesn't fix other common problems, however for average users of non-SSD disks it is an important baseline, especially in the long run. – Jure Sah Jul 3 '17 at 14:21

As you note, defrag at boot time allows you to move files that are normally in use by the system after boot. There is actually one case where these files need to be moved... if you are attempting to Shrink a partition to recover space for other uses. Say your C: drive needs more space and you wasted a lot of junk that can be removed on an F: drive. I used to be able to do this, but in Windows 2008, I might free up 75% of the space on a drive and end up only being able to Shrink the drive to half the size. It sounds like the -b option now works against any attempt to help free space at the end of a drive, so it can shrink, by moving program files out.

I find virtual disks are constantly in need of such maintenance when space gets tight. Oh well, at least in Hyper-V I can compact a dynamic drive to recover the empty space in the middle. It just introduces a false sense of capacity when you look at what the VM thinks is available.


So long as you do it properly it's not going to hurt, but the benefit of it really depends on the condition of your system.

Enter this in to notepad:

Rundll32.exe advapi32.dll,ProcessIdleTasks
defrag -b %SystemDrive%

save it as 1.bat on your desktop then right click it and run as admin. the first line tells it to wait until you've closed all running applications so it will just sit there if you have anything running.


Actually you can run defrag before Windows starts, just boot into the Recovery Environment, open a command prompt, go into de drive where Windows is installed something like: C:\windows\system32\ then type defrag and it will be running.


It depends on what you're trying to defrag. The point of boot time defrag is to attempt to defragment things like the master file table, and the pagefile (which is can be done using system internal's page defrag or other tools). I've never noticed a huge performance difference after defragmenting my page file (on the other hand on XP era systems, a normal defrag can seem like magic).

In short - there's no advantage to boot time defrag, over a good regular schedule of good old fashioned online defragmentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.