Wednesday, October 7, 2009

Windows 7 Boot Optimization Error

I am not sure if you guys know you can manually invoke Windows 7 defragmentation Tool to do boot optimization by using the /b flag.

When you run defrag.exe, you get the following
Microsoft Disk Defragmenter
Copyright (c) 2007 Microsoft Corp.

The parameter is incorrect. (0x80070057)

Description:

Locates and consolidates fragmented files on local volumes to
improve system performance.

Syntax:

defrag | /C | /E [/H] [/M | [/U] [/V]]
defrag | /C | /E /A [/H] [/M | [/U] [/V]]
defrag | /C | /E /X [/H] [/M | [/U] [/V]]
defrag /T [/H] [/U] [/V]

Parameters:

Value Description

/A Perform analysis on the specified volumes.

/C Perform the operation on all volumes.

/E Perform the operation on all volumes except those specified.

/H Run the operation at normal priority (default is low).

/M Run the operation on each volume in parallel in the background.

/T Track an operation already in progress on the specified volume.

/U Print the progress of the operation on the screen.

/V Print verbose output containing the fragmentation statistics.

/X Perform free space consolidation on the specified volumes.

Examples:

defrag C: /U /V
defrag C: D: /M
defrag C:\mountpoint /A /U
defrag /C /H /V

Notice there is no /B flag but it is there.
However on a fresh Windows 7 installation when you try to do this with Administrative Permission in a Command Prompt Window.
C:\Windows\system32>defrag C: /B
You get some message saying it cannot be done like the following:
Microsoft Disk Defragmenter
Copyright (c) 2007 Microsoft Corp.

Invoking boot optimization on (C:)...

Analysis: 100% complete.

Some registry entries were missing from the boot optimization section of the reg
istry. (0x89000017)

How to resolve this?
The issue is the idle tasks Windows is scheduled to run hasn't run once yet hence it cannot initialize boot optimization.
So to resolve simply open a Command Prompt Windows with Administrative Permission again and run the following commands to invoke the idle task.
C:\Windows\system32>Rundll32.exe advapi32.dll,ProcessIdleTasks
After that the error message will be gone and you can run boot optimization manually.

Why doesn't this happen sometimes?
Because RunIdle task is scheduled to run eventually after sometime of idle usage
if you do boot defrag immmediately after installation,
RunIdle task hasn't got a chance to run at all so you have to invoke it manually
if you want to start the operation immediately.

No comments:

Post a Comment