Monday, October 11, 2010

How to use bcdedit command tool?

1. Click Start Menu then at Start Search type cmd then press CTRL+SHIFT+Enter
or go to All Programs >> Accessories >> right click command prompt and select run as Administrator.

2. type bcdedit 
    It displays list if boot entries.

A boot entry consists of 4 main elements:
1. Identifier
The identifier is how the system has named the boot entry.
2. Device
The device is the drive or virtual image that the system will use to boot the boot entry.
3. Path
The path is the location on the device where the bootloader file is found.
4. Description
The description is the friendly name we give to our boot entry, e.g. "Windows 7"
You see next to the identifiers their UUIDs in {}. The UUID is the unique codename that the system gives to each boot entry and cannot be changed.

The standard identifier UUIDs are explained below:
{bootmgr} = the boot manager
{current} = the OS you selected to boot at startup.
{default} = the default OS selected to boot the PC.
{ntldr} = Windows Legacy OS Loader (for windows xp)
there are others like {memdiag} or {ramdisk} but they can't be of much use right now.

warning   Warning
IMPORTANT: make a backup of your bcd file first. To do that, type:

bcdedit /export C:\SAVEDBCD

This will create a file c:\savebcd which is your boot entry backup.
If you mess up, you can always undo changes by:

bcdedit /import c:\savedbcd

Now to see how we can control the above entries, here are some examples:
bcdedit /set {current} description "My edited Windows Boot Entry"
NOTE: This changes the title of the boot menu entry "{current}".

bcdedit /set {ntldr} device partition=E:
NOTE: This tells bcd that Windows XP partition is drive E:

bcdedit /set {ntldr} path \ntldr
NOTE: This tells bcd that the ntldr file which is the winxp bootloader is on root folder "\" (of drive e: as stated above)

bcdedit /displayorder {ntldr} /addfirst
NOTE: This places Windows XP as the first OS on the menu list.

bcdedit /default {ntldr} 
NOTE: This places Windows XP as the default OS to boot first with.

bcdedit /displayorder {33342343-3424-2342342342-2344} /addlast
NOTE: This tells bcd that the boot entry with UUID 3334... should be the last entry on the menu.
You can copy your existing VISTA or Windows 7 boot entry to another identical. Then you can change settings on the new entry to experiment. You will always have the first entry available, so it's safe to play with.
bcdedit /copy {current} /d "New Windows 7 boot entry I just copied!"
this will give you a line:
NOTE: The entry was successfully copied to {4c21825f-e04b-11dd-b760-00195b61617a}. The {4c21825f-e04b-11dd-b760-00195b61617a} is the UUID of the new entry that the system just created. Yours will be different than mine! This is its identifier and you should use this to address that entry. Example:

bcdedit /set {4c21825f-e04b-11dd-b760-00195b61617a} numpoc 2
NOTE: This adds the 2 CPU Core support during boot, like you do in msconfig.

bcdedit /deletevalue {4c21825f-e04b-11dd-b760-00195b61617a} numproc
NOTE: This deletes the numproc parameter from entry {4c21825f....}

bcdedit /delete {4c21825f-e04b-11dd-b760-00195b61617a} 
NOTE: This deletes the boot entry {4c21825f....} completely. In order to delete an {ntldr} entry, you must use the /f switch to force deletion: bcdedit /delete {ntldr} /f
You can always type just bcdedit to see your current settings.

What else can I do with BCDEDIT?

You can use BCDEDIT to alter any boot parameter , like you would in msconfig, only more. BCDEDIT works from booting with installation dvd too, so it can be handy for recovery purposes.
bcdedit /timeout 5
NOTE: This sets the wait-to-select-OS menu timeout at startup to 5 seconds . You will notice that I didn't give a UUID above. If you omit the UUID, it applies automatically to the relavant UUID. So: bcdedit /timeout 5 is identical tobcdedit /set {bootmgr} timeout 5
Some more advanced examples:
bcdedit /set {current} detecthal yes
bcdedit /set {current} detecthal no
NOTE: The above commands sets the detecthal to yes or no for entry {current}
To create a new boot entry to load Windows XP from a partition on your disk: 
NOTE: The example below uses F: as the Windows XP partition. Replace with your xp drive letter.
bcdedit /create {ntldr} /d "Windows XP"

bcdedit /set {ntldr} device partition=F:

bcdedit /set {ntldr} path \ntldr

bcdedit /displayorder {ntldr} /addlast
Note   Note
Final note: BCDEDIT works from installation boot dvd too. If you mess up with a setting and you cannot boot, just boot from DVD and enter Repair Computer, then go to command prompt and there you go. You can play again with bcdedit to restore your system back.

To change the description of the Windows Boot Manager:

bcdedit /set {current} Description "Vista Ultimate" 

No comments:

Post a Comment