Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Wednesday, November 2, 2011

BCDEDIT Command Line Tool

Source  (copied and pasted) read more there!
To do with privileges, and is a good reason for not disabling UAC. Although you may be running as an Administrator, you are only running with standard privileges. In order to run as a true Administrator, you need to elevate.
Bcdedit is a really powerful tool that Windows Vista and Windows 7 uses to manage the boot loader entries.
BCDEDIT needs a boot loader file to boot your system.
A boot loader is a file that contains necessary information that instruct the system how to boot/start an operating system.
  • Windows 7 and Vista bootloader file is \bootmgr
  • Windows XP bootloader file is \ntldr
BCDEDIT can support other bootloaders too, like grub for linux. You just have to place the bootloader file on the root of the boot manager partition. e.g. \grldr and you have a grub boot loader enabled.
Bcdedit edits a file called bcd , which is located in Windows 7's hidden partition under \boot\bcd.
In Vista, its located under C:\boot\bcd.
1. Open an elevated command prompt.

2. Type bcdedit and press enter.
NOTE: By typing just bcdedit you just list your boot entries.
Click this bar to view the full image.
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 to
bcdedit /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.
Recovering the Vista Bootloader from the DVD - NeoSmart Technologies Wiki
How can I configure it so that it wont offer a recovery option but starts windows normally? Or if offers then at least how can I configure it so that the "Start Windows normally" will be the default one in the list?
The default choice for the boot menu is in stored in "BCD-bootmgr-DefaultObject".
There is a utility called "Visual BCD Editor" - can be found here -> Free Windows BCD Editor - Windows 7 and Vista
This utility offers the full functionality of 'bcdedit' in an explorer like GUI. Moreover it is the first GUI utility to implement the full functionality of 'bcdedit'.
You can set your default loader choice by selecting the loader in the tree-view to the left, then click on the 'object' tab and in the tab click 'Set as Default Loader' button.
You can delete a loader by selecting the loader in the tree-view, right click, delete, confirm.
You can delete the menu entry for a loader by selecting {bootmgr} in the tree-view, then in Elements-view select 'DisplayOrder' and dbl-click. In the window that pops-up select the loader entry you want to delete, click on 'Delete' and then OK.
Windows always starts booting from first disk and active partition on that disk.
Boot sequence in short is:
MasterBootRecord, active PartitionBR, bootmgr (uses BCD from \boot), winload
Method 1:
1. Run Disk Management and check if Windows 7 is on the active partition. If not set the partition to active. (It is best if first partion is active)
2. Write MBR & PBR on Windows 7 disk (use bootsect.exe)
3. Repair/create Windows 7 boot files on Win 7 disk (bootmgr + \boot folder with BCD) (use bcdboot.exe)
4. In BIOS set Windows 7 disk to be first disk in boot sequence.
If you want detailed instructions post a disk map.
JUST UNPLUG VISTA DRIVE and Startup Repair - Run 3 Separate Times
I have CentOS 5.6 on my primary SATA drive. Windows 7 Ultimate is installed on second SATA drive. I did some edit of grub config to have Windows 7 boot from second drive and it works just perfect untill ... one note before. I use hd0, hd1 for drives decription - I guess, BIOS mimics PATA drives. sd0 sd1 don't work.
So, what happens. I can choose CentOS from hd0 or Windows7 from hd1 on grub loader menu and it works. Untill I installed one more Windows 7 instance on hd0. I can't boot hd1 Windows since. I tried to edit grub config: adding "mark active" and so. No help. Windows loader get's the control and doesn't boots from secondary drive.
Windows boot choice will help me, I guess. I understand bcdedit command, I see "bcd" file I need. what lines must be added to "bcd" to solve this?
The second instance of Windows overwrote your MBR, and failed to detect the first Windows on hd1. You can either work with the Windows loader, in which case I recommend EasyBCD, or you can repair the GRUB loader, which might be preferable since CentOS is your main OS. See TipsAndTricks/ReinstallGRUB - CentOS Wiki for some instructions for the latter.
When you say you marked Active, what did you mark active, and did you do so in GRUB, or in a partition manager?
not a case. If I take away new_Windows_7 from first hdd, grub boots old_Windows_7 from second hdd no problem. CentOS boots at any case.
I did it, actually. Now I can boot all CentOS systems from Grub and transfer boot control to Windows Boot menu. I can start Windows 7 from 2nd drive now. Sure, from the 1st also. Both versions of Windows works from c:. I like the automation. Volume letter is changing depending on which system is active even in boot loader configuration. Cool.
It is done from administration cmd prompt, a couple of bcdedit commands.
I don't need a EasyBCD unless it's for free

No comments: