UoA

Using BCDEdit

From Science IT

Jump to: navigation, search

How to use and troubleshoot the Windows Boot Manager application

Contents

Recovery

MBR / Boot Sector Recovery

When you install an earlier version of the Windows operating system on a Windows Vista-based or Windows 7-based computer, Setup overwrites everything from the MBR, the boot sector, and the boot files. Therefore, the earlier version the Windows operating system loses forward compatibility with Windows Vista.

To resolve these issues, follow these steps.

NOTE: You can run the commands in the following procedure by using the command prompt. If you run these commands in Windows Vista, run them at a command prompt that has elevated user rights. To do this, click Start, click Accessories, right-click the command-prompt shortcut, and then click Run as Administrator.

Use Bootsect.exe to restore the Windows Vista MBR and the boot code that transfers control to the Windows Boot Manager program. To do this, type the following command at a command prompt:

Drive:\boot\Bootsect.exe /NT60 All

In this command, Drive is the drive where the Windows Vista installation media is located.

NOTE: The boot folder for this step is on the DVD drive.

Use Bcdedit.exe to manually create an entry in the BCD Boot.ini file for the earlier version of the Windows operating system. To do this, type the following commands at a command prompt.

NOTE: In these commands, Drive is the drive where Windows Vista is installed.

Drive:\Windows\system32\Bcdedit /create {ntldr} /d "Description for earlier Windows version"

NOTE: In this command, Description for earlier Windows version can be any text that you want. For example, Description for earlier Windows version can be "Windows XP" or "Windows Server 2003".

Drive:\Windows\system32\Bcdedit /set {ntldr} device partition=x:

NOTE: In this command, x: is the drive letter for the active partition.

Drive:\Windows\system32\Bcdedit /set {ntldr} path \ntldr
Drive:\Windows\system32\Bcdedit /displayorder {ntldr} /addlast

Restart the computer.

Booting NT based OSs

To start versions of the Windows operating systems that are based on Microsoft Windows NT, you need the following files:

  • Ntldr
  • Boot.ini
  • Bootfont.bin

Note You need to use this file when you install the Windows versions of the East Asian languages.

  • NTDetect.com

In Windows XP, these files reside on the system partition that is marked "active." By default, these files are hidden system files in Windows XP. Users can replace these files by using the Recovery Console, or users can start the operating system by using a Windows NT boot disk. Windows Vista does not use these three files. Windows Vista starts by using the hidden system file Bootmgr and other required files that are located in the \Boot directory.

Creating a multi-boot configuration that includes Windows Vista

To create a working multi-boot configuration, install the oldest version of the Windows operating system first. Then, install each newer version in order. Every new Windows version preserves backward compatibility for starting earlier Windows versions.

To create a multi-boot configuration that includes Windows Vista, you must have at least one partition for each earlier Windows version that you install. Follow these general guidelines:

  • Create at least two partitions. Use one partition for the Windows Vista installation.

NOTE: If the partition for Windows Vista is already formatted, make sure that it is formatted by using the NTFS file system.

However, we recommend that you use one of the following methods:

  • Create the second unformatted partition.
  • Do not create the second partition and leave the space as free space. Instead, create the second partition during the Windows Vista installation.
  • If the computer does not have an operating system installed, install the oldest Windows version first.

NOTE: Install Windows XP before you install Windows Server 2003.

  • Run the Windows Vista Setup program. Install Windows Vista in the free space or in the existing partition. You can run this Setup program in the earlier Windows version, or you can start the computer when the Windows Vista disc is in the CD or DVD drive.

After Windows Vista Setup finishes, you will have a correctly-configured, multi-boot environment that includes Windows Vista and the earlier versions of Windows. The Bootmgr boot menu that appears resembles the following menu:

Microsoft Windows Earlier Windows Operating System

Removing Windows Vista from a dual-boot configuration

If you want to remove Windows Vista from a dual-boot environment that includes an earlier version of Windows, follow these steps.

NOTE: You can follow these steps in the earlier version of Windows or in Windows Vista. If you follow these steps in Windows Vista, run the commands from a command-prompt that has elevated user rights. To do this, click Start, click Accessories, right-click the command-prompt shortcut, and then click Run as Administrator.

Use Bootsect.exe to restore the Ntldr program. To do this, type the following command:

Drive:\Boot\Bootsect.exe /NT52 All

NOTE: In this command, Drive is the drive where the Windows Vista media is located.

After the computer restarts, it does not load the Windows Boot Manager program. Instead, Netldr.exe loads and Boot.ini loads.

Delete or remove the partition where Windows Vista is installed.

NOTE: You can only delete the partition where Windows Vista is installed if that partition is the non-active partition on the system. For example, consider the following scenario:

  • Windows Vista is installed on drive C. Drive C is partition 1 and is the active partition.
  • Windows XP is installed on the drive D. Drive D is partition 2 and is the non-active partition.

In this scenario, you can run the bootsect command, but you cannot delete the partition where Windows Vista is installed. If you delete this partition, the computer is put into a non-bootable state because Windows XP boot files are deleted.

BootRec Tool

You can use the Bootrec.exe tool in the Windows Recovery Environment (Windows RE) to troubleshoot and repair the following items in Windows Vista or Windows 7:

   * A master boot record (MBR)
   * A boot sector
   * A Boot Configuration Data (BCD) store

NOTE: When you are troubleshooting startup issues by using the Windows RE, you should first try the Startup Repair option in the System Recovery Options dialog box. If the Startup Repair option does not resolve the issue, or if you must troubleshoot more steps manually, use the Bootrec.exe tool.

To run the Bootrec.exe tool, you must start Windows RE. To do this, follow these steps:

Put the Windows Vista or Windows 7 installation disc in the disc drive, and then start the computer.
Press a key when you are prompted.
Select a language, a time, a currency, a keyboard or an input method, and then click Next.
Click Repair your computer.
Click the operating system that you want to repair, and then click Next.
In the System Recovery Options dialog box, click Command Prompt.
Type Bootrec.exe, and then press ENTER.

NOTE: To start the computer from the Windows Vista or Windows 7 DVD, the computer must be configured to start from the DVD drive. For more information about how to configure the computer to start from the DVD drive, see the documentation that is included with the computer or contact the computer manufacturer.

BootRec Options

The Bootrec.exe tool supports the following options. Use the option that is appropriate for your situation.

NOTE: If rebuilding the BCD does not resolve the startup issue, you can export and delete the BCD, and then run this option again. By doing this, you make sure that the BCD is completely rebuilt. To do this, type the following commands at the Windows RE command prompt:

bcdedit /export C:\BCD_Backup
c:
cd boot
attrib bcd -s -h -r
ren c:\boot\bcd bcd.old
bootrec /RebuildBcd
  • /ScanOs

The /ScanOs option scans all disks for installations that are compatible with Windows Vista or Windows 7. Additionally, this option displays the entries that are currently not in the BCD store. Use this option when there are Windows Vista or Windows 7 installations that the Boot Manager menu does not list.

  • /RebuildBcd

The /RebuildBcd option scans all disks for installations that are compatible with Windows Vista or Windows 7. Additionally, this option lets you select the installations that you want to add to the BCD store. Use this option when you must completely rebuild the BCD.

  • /FixMbr

The /FixMbr option writes a Windows 7 or Windows Vista-compatible MBR to the system partition. This option does not overwrite the existing partition table. Use this option when you must resolve MBR corruption issues, or when you have to remove non-standard code from the MBR.

  • /FixBoot

The /FixBoot option writes a new boot sector to the system partition by using a boot sector that is compatible with Windows Vista or Windows 7. Use this option if one of the following conditions is true:

  • The boot sector has been replaced with a non-standard Windows Vista or Windows 7 boot sector.
  • The boot sector is damaged.
  • An earlier Windows operating system has been installed after Windows Vista or Windows 7 was installed. In this scenario, the computer starts by using Windows NT Loader (NTLDR) instead of Windows Boot Manager (Bootmgr.exe).

Recreating the Boot Configuration Datastore

del c:\boot\bcd
bcdedit /createstore c:\boot.bcd.temp
bcdedit /store c:\boot\bcd.temp /create {bootmgr} /d "Windows Boot Manager"
bcdedit /import c:\boot\bcd.temp
bcdedit /set {bootmgr} device partition=C:
bcdedit /timeout 10
del c:\boot\bcd.temp
bcdedit /create /d "Windows Vista" /application osloader

copy the GUID string from the output of the last command

bcdedit /set {ee186ddd-20c1-11df-aa50-0022191bf8ff} device partition=C:
bcdedit /set {ee186ddd-20c1-11df-aa50-0022191bf8ff} osdevice partition=C:
bcdedit /set {ee186ddd-20c1-11df-aa50-0022191bf8ff} path \Windows\System32\winload.exe
bcdedit /set {ee186ddd-20c1-11df-aa50-0022191bf8ff} systemroot \Windows
bcdedit /displayorder {ee186ddd-20c1-11df-aa50-0022191bf8ff}

Boot WinPE from hard disk

@echo off
rem   Note: This script for WinPE for Windows Vista sp1
rem
rem   For adding entries into the BCD store to set up WinPE to load from a HDD location.
rem   The boot files are copied from a working WinPE bootable CDrom disk.
rem   The point is to be able to boot WinPE from the HDD without needing to find the
rem    bootable CD disk. 
rem
rem   For safety this script exports the system BCD store to a temporary store
rem    then edits the temporary store. After success, the temporary store is
rem    imported into the system BCD store.
rem
rem   As scripted here, the WinPE boot files must exist on this drive and path:
rem     drive   D:        ( variable WPDrv )
rem     folder  \wpeboot  ( variable WPPth )
rem   The Drive and Path to the WinPE boot files can be changed by
rem    modifying two cmd.exe set statements (below) before executing this script.
rem   To change the location later, run the 'delete' script, move the files,
rem    modify this script and add the settings again.
rem
rem   Typically there will be two WinPE boot files 
rem     boot.Wim          ( variable WimNm )
rem     boot.Sdi          ( variable SdiNm )
rem   You will copy them manually from the working Winpe boot cd rom disk
rem    \sources\boot.wim and \boot\boot.sdi locations into the D:\wpeboot folder.
rem   Assuming that the WinPE boot CD was created normally the .wim
rem    file is named boot.wim and the .sdi file is named boot.sdi 
rem    If you rename them you must fix the set statements (below) appropriately.
rem
rem   This script creates the osloader entry and the device options entry for it,
rem     obtaining the randomly created GUIDs (variables guid1 and guid2).
rem   This script also creates 'DelWinpe.cmd' command file for you to use if
rem     required to remove those two entries from the BCD store. This also gives
rem     you a permanent record of the two ramdomly generated GUIDs. 
echo Exporting the system BCD store to BcdTemp
bcdedit /export BcdTemp
if errorlevel 1 echo Error - we need to have admin privileges.
if errorlevel 1 goto Endit
rem Set the name of the Winpe .wim file
set WimNm=boot.wim
rem Set the name of the WinPE .sdi file
set SdiNm=boot.sdi
rem Set the drive where the two WinPE boot files are located ( x: with no \ )
set WPDrv=D:
rem Set the folder path to the WinPE boot files ( no drive letter, no trailing \ )
set WPPth=\wpeboot
rem Description that shows up in the boot menu
set WPDes="WinPE 6.0.6001 (Vista sp1)"
rem Create the osloader and device options entries in the bcd store.
rem Get the randomly created GUID numbers that uniquely identify our two entries.
For /F "tokens=3 delims= " %%1 in ('bcdedit.exe /store BcdTemp /create /application OSLOADER /d %WPDes%') do set guid1=%%1
echo Osloader entry id is %guid1%
For /F "tokens=3 delims= " %%1 in ('bcdedit.exe /store BcdTemp /create /device /d %WPDes%') do set guid2=%%1
echo Device options entry id is %guid2%
echo Setting items in the osloader entry
bcdedit /store BcdTemp /set %guid1% device ramdisk=[%WPDrv%]%WPPth%\%WimNm%,%guid2%
bcdedit /store BcdTemp /set %guid1% osdevice ramdisk=[%WPDrv%]%WPPth%\%WimNm%,%guid2%
bcdedit /store BcdTemp /set %guid1% path \windows\system32\boot\winload.exe
bcdedit /store BcdTemp /set %guid1% locale en-US
bcdedit /store BcdTemp /set %guid1% inherit {bootloadersettings}
bcdedit /store BcdTemp /set %guid1% systemroot \windows
bcdedit /store BcdTemp /set %guid1% detecthal Yes
bcdedit /store BcdTemp /set %guid1% winpe Yes
bcdedit /store BcdTemp /set %guid1% ems No
echo Setting items in the device options entry
bcdedit /store BcdTemp /set %guid2% ramdisksdidevice partition=%WPDrv%
bcdedit /store BcdTemp /set %guid2% ramdisksdipath %WPPth%\%SdiNm%
echo Setting bootmgr to include the WinPE entry in the boot display list
bcdedit /store BcdTemp /set {bootmgr} displayorder %guid1% /addlast
rem Create an undo cmd file to delete the entries directly from the system bcd store.
echo Creating the DelWinpe.cmd undo command file
echo bcdedit /delete %guid1% >>DelWinpe.cmd
echo bcdedit /delete %guid2% >>DelWinpe.cmd
echo Display bootmgr and the two new entries
bcdedit /store BcdTemp /enum {bootmgr}
bcdedit /store BcdTemp /enum %guid1%
bcdedit /store BcdTemp /enum %guid2%
echo.
If errorlevel 1 echo Error - something went awry. Not importing the temporary store.
If errorlevel 1 goto Endit
echo Ready to import the temporary store into bcd system store...
pause
echo Importing BcdTemp into the system BCD store.
bcdedit /import BcdTemp
:Endit
set guid1=
set guid2=
set WpDrv=
set WPPth=
set WimNm=
set SdiNm=
set WPDes=
echo done
This page was last modified on 16 March 2010, at 10:55. This page has been accessed 1,879 times.
Categories

Personal tools