Some time ago I wrote an article here exposing the Tune XP tool's supposed magic for defraging the OS boot files. I found what it did and wrote a method for Vista users to do this boot file defrag themselves.
Since I just converted to Win7, I was anxious to see how my method worked with Win7. I am happy to report it works well, and in fact under Win7 it is much more illuminating as to what is happening. Follow along below for details.
First some background info. Win7 and Vista both have an automated process for defragging the boot files. However, under Vista (not sure about Win7 yet) many laptop users never have this automated process kick in. Why? Because the process is designed to start only if the machine is left idle for a period of time. Most laptops are not left idle long enough for the process to trigger, hence the need for a manual way to force the defrag.
Attached to this post is a file named DefragBootFiles.ZIP. (This is EXACTLY the same file that appeared in my post about defragging Vista boot files.) It contains a batch file with two lines:
(If you choose to create your own file DO NOT NAME IT DEFRAG.BAT! If you do it will cause the batch file to loop over and over!)Code:Rundll32.exe advapi32.dll,ProcessIdleTasks defrag -b %SystemDrive%
Open the zip file and move the batch file file to your desktop. Close ALL running applications.
Then right click on it and select run as administrator. The first line just tells Win7 that all applications are idle and it can start a background task that is just sitting there waiting for this event to occur. That task analyzes the boot file history that Win7 maintains and creates a file with the optimum order for these files. The second line starts a specialized defrag process that uses that ordering information and puts these boot files into the proper sequence!
When you run the batch file it will popup a command window and looks like it is just sitting there hung on the first line. It's not, trust me. Read on...
If you open Task Manager and view all running processes, the two processes (Defrag and DfrgNTFS) that showed up when we did this under Vista, no longer show up. Instead there is a service that does. In Task Manager if you switch to the Services tab and sort by name you will see defragsvc running. This is a service that is always loaded under Win7 but remains stopped until needed. The line in the batch that forces the idle tasks to start will wake up this service. If you switch to the Performance tab in Task Manager and click the Resource Monitor button, you can then click in the check box to the left of svchost.exe(defragsvc)" and then open the disk IO segment of the resource monitor. There you can see just the IO that the defragsvc is doing. Also the CPU and DISKIO graphs will then have an additional orange trace just for the stuff the defragsvc is doing. Check this out:
![]()
Even cooler, the defrag command in the batch file now has some output. (For those of you who used my batch file under Vista you'll remember that the command window never showed ANYTHING.) If you watch the command window where the batch file is running, when the batch file gets to the second line (and this can take a few minutes as the first line in the batch file takes a while to execute) you will see:
When the two lines in the batch file are done the command window will disappear.Code:C:\Windows\system32>defrag -b C: Microsoft Disk Defragmenter Copyright (c) 2007 Microsoft Corp. Invoking boot optimization on (C:)... Pre-Defragmentation Report: Volume Information: Volume size = 49.99 GB Free space = 21.12 GB Total fragmented space = 2% Largest free space size = 4.59 GB Note: File fragments larger than 64MB are not included in the fragmentation statistics.
Now some IMPORTANT words of caution: Be patient, give it some time. It can take anywhere from a few seconds to an hour even. Just depends on how fragmented your files are. I just ran it and it took about seven minutes. Your disk drive light will show LOTS of activity.
Sit back, have a cup of coffee or whatever. Just wait until the command window disappears. That cannot be stressed highly enough! DO NOT CLOSE THE COMMAND WINDOW! BE PATIENT! LET IT FINISH! Now reboot and see if it made any difference in boot time.
A couple of additional notes:
First, the defragsvc will continue to show as "running" in the Services tab of Task Manager for a period of time, even after the command window goes away. It will eventually switch back to a "stopped" status all by its self. Second, on a clean install of Win7 you may not see a drastic improvement in boot times. It depends on how many drivers you had to install your self and how many were done by the Win7 install. It is perfectly safe to run this batch whenever you want, but the only time you NEED to run it is after you have updated a driver or an application that loads as a program at boot time or runs as a service (which are always loaded at boot time.)
One more parting warning: DO NOT CLOSE THE COMMAND WINDOW!
Gary
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Attached Files:
-
-
Thx for posting this. Have Win7 64 with a lot of drivers and startup programs installed myself and not through windows update.
However maybe the automated process had already kicked in cause I ran the file from desktop and there was no time gained when booting up. Shall try again after installing newer drivers or startup programs. -
ScuderiaConchiglia NBR Vaio Team Curmudgeon
brownstonemr,
On a fresh, clean install, I am not surprised at the results you got. There would be very little fragmentation. Plus the jury is still out on how Win7 handles the automated process. They may have fixed it, I just don't know. I do know under Vista, unless you let your laptop sit idle (few of us do), the process never kicked in.
I think we'll know more over time as we try this after the Win7 has been in wide use for a few months.
Gary -
Thanks man for sharing that. I just used your method, it finished within few minutes. Maybe BC I use regularly MyDefrag, famous ex-JKDefrag.exe. I'll update later with the gains. +Rep for that.
-
I ran this in Windows 7 64-bit. The command window opened, "invoking boot file optimization" displayed after some time and then the command windows disappeared. I don't know if the optimization is complete. In the registry entry "HKLM > Dfrg > BootOptimizeFunction, it says "No" for OptimizeComplete.
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Were you monitoring it with TaskManager and Resource monitor as suggested?
Gary -
Finally it ran successfully, when I tried it for the third time. I could see the registry entry "Yes" for BootOptimizeFunction now. I don't what was going on for the first two times I tried. I read somewhere that on a fresh Windows 7 install, Windows takes some time to start the auto boot optimization and the registry entries (not there before) will be created later, as I can see the new entries now.
-
Anyone notice a difference after doing this? I need a boot timer program....
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
As with Vista, this defrag will be more beneficial down the road as we install new drivers, new services and new apps that run at boot time.
I haven't seen any info about whether or not Microsoft tweaked the scheduled task under Win7 that is supposed to do this automatically. The way it was configured under Vista it rarely got run on most laptops.
Gary -
Just ran this on my clean install (Sony FW285). Improved about 15-20 seconds. Thanks much!
Rep -
tilleroftheearth Wisdom listens quietly...
Just tried this on my VAIO (3+ month old install plus PerfectDisk 10) and boot times got worse.
I guess PerfectDisk does it better.
Shut down 13 secs (was 10)
Boot to DT 57 secs (was 45)
Usable Tot 145 secs (was 120)
Above are average of 3 runs for each test.
same methodology as:
http://forum.notebookreview.com/showthread.php?t=435052
This does work good though for newly installed systems.
However, does the first line 'processidletasks' work in Win 7? I seem to recall that it never did anything for me when the system was newly installed in the summer (2nd line 'defrag' does work, but I had to leave Win 7 at the desktop for a few hours to processidletasks automatically)? -
ScuderiaConchiglia NBR Vaio Team Curmudgeon
RE: Your times going up. What were they before?
Gary -
Thanks for this.
-
davepermen Notebook Nobel Laureate
-
tilleroftheearth Wisdom listens quietly...
having just clean installed Win 7 x64 on a Patriot Torqx 64GB SSD, I just wanted to say that yes, the idleprocesstasks command does work in Win 7 (I guess my running system just does it so fast I didn't think it was working).
Also of note is that although I had to manually disable the scheduled defrag in Win 7 because of the SSD, when I tried to run 'defrag c: -b' it gave an error that there were some files missing in the registry and did not run it.
So, I guess Win 7 does turn off defrag for the SSD, but leaves the scheduled defrag enabled just in case you plug mechanical HD's in at a later time. -
davepermen Notebook Nobel Laureate
yes, which is why i allways say DON'T TWEAK THE OS. leave scheduled defrag on.
-
-Amadeus Excello- Notebook Evangelist
Thanks for bringing this tweak/enhancement to my attention.
-
-
-
What happens if you do accidentally close the command window during the first line before it finishes?
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Seriously, I don't know WHAT might happen. All I can tell you is you should not close it until it finishes. Beyond that I am afraid you are on your own. It might really hose things up resulting in an unbootable machine. It might do no harm at all. I just cant say.
Gary -
I found that after doing this process my laptop booted up much slower. So I system restored. It appears that doing this boot file defrag actually increased my boot time by 45-60 seconds.
-
However, increased boot-time? It's strange. -
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Gary -
-
I have a U81a and tried this out, usually I use Diskperfect 10 and here is what I've found;
1.) boot time to desktop 51 seconds with having run diskperfect timed from power button press.
2.) After runing the batch boot times went to 65 seconds to desktop from the power button press.
3.) Ran diskperfect 10, it did show some boot files moved from the front of the drive.
4.) tested boot from power button press and now 50 second boot to desktop.
Now it takes from power button press to loosing the bios post 9-10 seconds for me too. So for now I'll keep using Diskperfect 10. Was hoping I didn't have too................ -
wow this really worked, thanks gary. Will this work on windows xp?
Rep + btw -
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Gary -
OK, I tried the script on my VAIO_F11, i7-720QM, 6 GB memory, GT 330M, Win 7 64-bit Ultimate and 500GB 7200 RPM Seagate Momentus.
I created a restore point, downloaded the Restart Time small script & after optimizing my Restart time with Autoruns for Windows v9.57, I measured consistently 63 sec. on the Balanced Power Plan & 60 sec on Performance:
Then I ran the DefragBootFiles.bat you suggested following EXACTLY the how-to instructions. It took about 12 minutes to complete:
Then I ran again Restart Time to see the result of the boot files defrag: 85 sec.!
Now I don't know if it's Windows 7 or the utility I found in the OEM recovery disc #2 that I extracted with SonyExtractor_v0.1a: MOD-PC_Boot_Optimization.mod > MOD-PC_Boot_Optimization.EXE > installed as: PC Boot Optimization:
But I ran several time the Restart Time script & my results kept on getting better & better to finally stabilize @ 55 sec.
-
Windows defrag utility does this just by using a short command. You just have to open the CMD with admin rights and then run "defrag C: -b".
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Gary -
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
So yes, the defrag might very well run without the first step. But there is really no point in skipping it, so that you are sure you have an up to date list of files and optimization info. It only takes a couple of minutes more and then you are certain of having a fully optimized boot defrag.
Gary -
If you use SuperFetch, is this process needed?
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Gary -
question is it possible for you to do the same thing but make it for your steam folder and movies? I would love to see you take it to the next lvl where movies and music can be put on the inner part of the platter and games and apps on the outer part.
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Gary -
Well that blows. On my external there is a huge difference...even on my internals. I put all my games on my external because its far faster. Faster transfer rates would help loading times alot. I have noticed a difference from my internal to my external already. My external outer parts are 130MBps and inner parts are 70-80MBps. Thats a huge difference. My internal has a 50% difference almost too. Here are the benchmarks. Is there any program that can do that?
ImageShack Album - 3 images -
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Gary -
alright thx. I'll try to google this but i bet i am out of luck ^^. The only reason why i care is that if i can find a program to do it. It should be easy and not take very much effort to get a nice little boost in load times.
EDIT: side note check this thread i made. In my process of testing my external and stuff. I found out that HDTune Pro is not accurate. For some reason it gives false results as i show here.
http://forum.notebookreview.com/win...hdtune-hdtune-pro-inaccurate.html#post6744790 -
I have been using this on all my computers and just today when I did a fresh install of windows 7 I used it but I got an error that something in the boot registry wasnt there. I ran ccleaner just a little bit before so i am thinking something might have gotten deleted. Any idea?
-
ScuderiaConchiglia NBR Vaio Team Curmudgeon
Gary -
He/she probably tried running defrag c: -b command on a fresh Windows install or without allowing Windows prior opportunity to optimize itself.
He/she has to run a command in the command prompt that will force start background idle tasks.
Type in the following command in command prompt (using admin priviledges):
Rundll32.exe advapi32.dll,ProcessIdleTasks
You won't have an indication on how long this forced optimization of background tasks will take (use resource monitor to see your disk activity and everything else for an indication)... give it an hour or two.
After that, you will be able to use/run the "defrag c: -b" command without a problem.
I also thought it was due to Ccleaner at first, until I looked into the problem deeper.
Ccleaner is perfectly safe to use and will NOT delete any vital parts of the registry that Windows needs for it's functions.
I have yet to encounter such issues.
I would instead avoid using any other program than Ccleaner for registry cleanup. -
ScuderiaConchiglia NBR Vaio Team Curmudgeon
It may not be CCleaner, but I would still very much like to see the actual text of the error message he got. To be honest, while the ProcessIdleTasks step is necessary, I don't thing running the defrag without it would result in an error message that mentions the registry. But then again, the actual error message text would be VERY helpful.
I am not a fan of generic use of any registry cleaners and only use them to resolve very specific ERROR situations.
Gary
P.S. Upon further reflection you might very well be right, if the ProcessIdleTasks had NEVER EVER been run before (as might be the case on a new install like this), the boot file optimization parameters would not exist and the defrag would not be able to find those parameters. I don't think they are stored in the registry though, BUT a pointer to them MIGHT be put in the registry and that may have been what the defrag was complaining about. But without that error text I am just speculating.
I have a feeling though that the ProcessIdleTasks step was done since the poster has been using my batch file in the past to boot file defrag other machines.
Defragmenting boot files under Win7
Discussion in 'Windows OS and Software' started by ScuderiaConchiglia, Oct 29, 2009.