BCDBoot 命令列選項BCDBoot Command-Line Options

BCDBoot 是一種命令列工具,用來設定電腦或裝置上執行 Windows 作業系統的開機檔案。BCDBoot is a command-line tool used to configure the boot files on a PC or device to run the Windows operating system. 您可以在下列案例中使用此工具:You can use the tool in the following scenarios:

  • 套用新的 Windows 映像之後,將開機檔案新增至電腦。Add boot files to a PC after applying a new Windows image. 在一般以映像為基礎的 Windows 部署中,使用 BCDBoot 來設定要開機至映像的韌體和系統磁碟分割。In a typical image-based Windows deployment, use BCDBoot to set up the firmware and system partition to boot to your image. 若要深入了解,請參閱擷取及套用 Windows、系統和復原磁碟分割To learn more, see Capture and Apply Windows, System, and Recovery Partitions.
  • 將電腦設定為開機至包含 Windows 映像的虛擬硬碟 (VHD) 檔案。Set up the PC to boot to a virtual hard disk (VHD) file that includes a Windows image. 若要深入了解,請參閱開機至 VHD (原生開機):將虛擬硬碟新增至開機功能表To learn more, see Boot to VHD (Native Boot): Add a Virtual Hard Disk to the Boot Menu.
  • 修復系統磁碟分割。Repair the system partition. 如果系統磁碟分割已損毀,您可使用 BCDBoot 來重建系統磁碟分割檔案,其做法是使用 Windows 磁碟分割中這些檔案的新複本。If the system partition has been corrupted, you can use BCDBoot to recreate the system partition files by using new copies of these files from the Windows partition.
  • 設定修復雙系統開機電腦上的開機功能表。Set up or repair the boot menu on a dual-boot PC. 如果您已在電腦上安裝一個以上的 Windows 複本,則可使用 BCDBoot 來新增或修復開機功能表。If you've installed more than one copy of Windows on a PC, you can use BCDBoot to add or repair the boot menu.

檔案位置File Locations

在 Windows 和 Windows 預先安裝環境 (WinPE) 中In Windows and Windows Preinstallation Environment (WinPE)

%WINDIR%\System32\BCDBoot.exe%WINDIR%\System32\BCDBoot.exe

在 Windows 評定及部署套件 (Windows ADK) 中:In the Windows Assessment and Deployment Kit (Windows ADK):

C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\BCDBoot\BCDBoot.exeC:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\amd64\BCDBoot\BCDBoot.exe

支援的作業系統Supported operating systems

BCDBoot 可以從 Windows 10、Windows 8.1、Windows 8、Windows 7、Windows Vista、Windows Server 2016 Technical Preview、Windows Server 2012 R2、Windows Server 2012、Windows Server 2008 R2 或 Windows Server 2008 的映像複製開機環境檔案。BCDBoot can copy boot environment files from images of Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Vista, Windows Server 2016 Technical Preview, Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 R2, or Windows Server 2008.

運作方式How It Works

若要設定系統磁碟分割,BCDBoot 會從已安裝的 Windows 映像將一小組開機環境檔案複製到系統磁碟分割。To configure the system partition, BCDBoot copies a small set of boot-environment files from the installed Windows image to the system partition.

BCDBoot 可以使用最新版的 Windows 檔案,在系統磁碟分割上建立開機設定資料 (BCD) 存放區:BCDBoot can create a Boot Configuration Data (BCD) store on the system partition using the latest version of the Windows files:

  • BCDBoot 會使用 WINDIR%\System32\Config\BCD-Template 檔案,建立新的 BCD 存放區並初始化系統磁碟分割上的 BCD 開機環境檔案,包括 Windows 開機管理程式。BCDBoot creates a new BCD store and initialize the BCD boot-environment files on the system partition, including the Windows Boot Manager, using the %WINDIR%\System32\Config\BCD-Template file.
  • Windows 10 的新功能:在升級期間,BCDBoot 會在建立新的存放區時,保留任何其他現有的開機項目,例如 debugsettingsNew in Windows 10: During an upgrade, BCDBoot preserves any other existing boot entries, such as debugsettings, when creating the new store. 使用 /c 選項來忽略舊設定,並使用新的 BCD 存放區重新開始。Use the /c option to ignore the old settings and start fresh with a new BCD store.
  • 如果已經有此 Windows 磁碟分割的開機項目,則 BCDBoot 預設會清除舊的開機項目和其值。If there is already a boot entry for this Windows partition, by default, BCDBoot erases the old boot entry and its values. 當您更新系統檔案時,請使用 /m 選項來保留現有開機項目中的值。Use the /m option to retain the values from an existing boot entry when you update the system files.
  • 根據預設,BCDBoot 會將所選 Windows 磁碟分割的開機項目移至 Windows 開機管理程式開機順序的頂端。By default, BCDBoot moves the boot entry for the selected Windows partition to the top of the Windows Boot Manager boot order. 使用 /d 選項來保留現有的開機順序。Use the /d option to preserve the existing boot order.

在 UEFI 電腦上,BCDBoot 可以更新裝置 NVRAM 中的韌體項目:On UEFI PCs, BCDBoot can update the firmware entries in the device’s NVRAM:

  • BCDBoot 會在 NVRAM 中新增一個韌體項目,以指向 Windows 開機管理程式。BCDBoot adds a firmware entry in the NVRAM to point to the Windows Boot Manager. 根據預設,此項目會置放成為開機清單中的第一個項目。By default, this entry is placed as the first item in the boot list. 使用 /p 選項來保留現有的 UEFI 開機順序。Use the /p option to preserve the existing UEFI boot order. 使用 /addlast 將其新增至開機順序清單的底部。Use /addlast to add it to the bottom of the boot order list.

命令列選項Command-Line Options

BCDBoot.exe 有下列可用的命令列選項。The following command-line options are available for BCDBoot.exe.

BCDBOOT <source> [ /l <locale>] [ /s <volume-letter> [ /f <firmware type>]] [ /v] [ /m [{OS Loader GUID}]] [ /addlast or /p] [ /d] [ /c]BCDBOOT <source> [/l <locale>] [/s <volume-letter> [/f <firmware type>]] [/v] [/m [{OS Loader GUID}]] [/addlast or /p] [/d] [/c]

選項Option 說明Description

<source><source>

必要。Required. 指定 Windows 目錄位置以作為複製開機環境檔案的來源。Specifies the location of the Windows directory to use as the source for copying boot-environment files.

下列範例會使用C:\Windows 資料夾中的 BCD 檔案來初始化系統磁碟分割:The following example initializes the system partition by using BCD files from the C:\Windows folder:

bcdboot C:\Windows

/l <locale>/l <locale>

選擇性。Optional. 指定地區設定。Specifies the locale. 預設值為美式英文 (en-us)。The default is US English (en-us).

下列範例會將預設 BCD 地區設定設為日文:The following example sets the default BCD locale to Japanese:

bcdboot C:\Windows /l ja-jp

/s <volume letter>/s <volume letter>

選擇性。Optional. 指定系統磁碟分割的磁碟區代號。Specifies the volume letter of the system partition. 在一般部署案例中不得使用此選項。This option should not be used in typical deployment scenarios.

當您要設定將在另一部電腦上開機的磁碟機 (例如 USB 快閃磁碟機或次要硬碟) 時,請使用此設定來指定系統磁碟分割。Use this setting to specify a system partition when you are configuring a drive that will be booted on another computer, such as a USB flash drive or a secondary hard drive.

UEFIUEFI:

  • BCDBoot 會將開機檔案複製到 EFI 系統磁碟分割,或 /s 選項所指定的磁碟分割。BCDBoot copies the boot files to either the EFI system partition, or the partition specified by the /s option.

    BCDBoot 會在相同的磁碟分割中建立 BCD 存放區。BCDBoot creates the BCD store in the same partition.

    根據預設,BCDBoot 會在韌體的 NVRAM 中建立 Windows 開機管理程式項目,以識別系統磁碟分割上的開機檔案。By default, BCDBoot creates a Windows Boot Manager entry in the NVRAM on the firmware to identify the boot files on the system partition. 若已使用 /s 選項,則不會建立此項目。If the /s option is used, then this entry is not created. 相反地,BCDBoot 會依賴預設韌體設定來識別系統磁碟分割上的開機檔案。Instead, BCDBoot relies on the default firmware settings to identify the boot files on the system partition. 根據 UEFI 2.3.1 規格,預設韌體設定應會開啟 EFI 系統磁碟分割 (ESP) 中的檔案:\efi\boot\bootx64.efi。By the UEFI 2.3.1 spec, the default firmware settings should open the file: \efi\boot\bootx64.efi in the EFI System Partition (ESP).

BIOSBIOS:

  1. BCDBoot 會將開機檔案複製到主要硬碟上的使用中磁碟分割,或是 /s 選項所指定的磁碟分割。BCDBoot copies the boot files to either the active partition on the primary hard drive, or the partition specified by the /s option.

  2. BCDBoot 會在相同的磁碟分割中建立 BCD 存放區。BCDBoot creates the BCD store in the same partition.

下列範例會將 BCD 檔案從 C:\Windows 資料夾複製到次要硬碟上將在另一部電腦上開機的系統磁碟分割。The following example copies BCD files from the C:\Windows folder to a system partition on a secondary hard drive that will be booted on another computer. 次要磁碟機上的系統磁碟分割已被指派磁碟區代號 SThe system partition on the secondary drive was assigned the volume letter S:

bcdboot C:\Windows /s S:

下列範例會在具有磁碟區代號 S 的 USB 快閃磁碟機上建立開機項目,包括支援 UEFI 型或 BIOS 型電腦的開機檔案:The following example creates boot entries on a USB flash drive with the volume letter S, including boot files to support either a UEFI-based or a BIOS-based computer:

bcdboot C:\Windows /s S: /f ALL

/f <firmware type>/f <firmware type>

選擇性。Optional. 指定韌體類型。Specifies the firmware type. 有效值包括 UEFIBIOSALLValid values include UEFI, BIOS, and ALL.

  • 在 BIOS/MBR 型系統上,預設值為 BIOSOn BIOS/MBR-based systems, the default value is BIOS. 此選項會在系統磁碟分割上建立 \Boot 目錄,並將所有必要的開機環境檔案複製到這個目錄。This option creates the \Boot directory on the system partition and copies all required boot-environment files to this directory.

  • 在 UEFI/GPT 型系統上,預設值為 UEFIOn UEFI/GPT-based systems, the default value is UEFI. 此選項會建立 \Efi\Microsoft\Boot 目錄,並將所有必要的開機環境檔案複製到這個目錄。This option creates the \Efi\Microsoft\Boot directory and copies all required boot-environment files to this directory.

  • 當您指定 ALL 值時,BCDBoot 會同時建立 \Boot\Efi\Microsoft\Boot 目錄,並將適用於 BIOS 和 UEFI 的所有必要開機環境檔案複製到這些目錄。When you specify the ALL value, BCDBoot creates both the \Boot and the \Efi\Microsoft\Boot directories, and copies all required boot-environment files for BIOS and UEFI to these directories.

如果您指定 /f 選項,則也必須指定 /s 選項,以識別系統磁碟分割的磁碟區代號。If you specify the /f option, you must also specify the /s option to identify the volume letter of the system partition.

下列範例會將支援在 UEFI 型或 BIOS 型電腦上開機的 BCD 檔案,從 C:\Windows 資料夾複製到已被指派磁碟區代號 S 的 USB 快閃磁碟機:The following example copies BCD files that support booting on either a UEFI-based or a BIOS-based computer from the C:\Windows folder to a USB flash drive that was assigned the volume letter S:

bcdboot C:\Windows /s S: /f ALL 

/v/v

選擇性。Optional. 啟用詳細資訊模式。Enables verbose mode. 範例:Example:

bcdboot C:\Windows /v

/m [{OS Loader GUID}]/m [{OS Loader GUID}]

選擇性。Optional. 將現有開機項目的值合併到新的開機項目。Merges the values from an existing boot entry into a new boot entry.

根據預設,此選項只會合併全域物件。By default, this option merges only global objects. 如果您指定 OS Loader GUID,此選項會在系統範本中合併載入器物件,以產生可開機的項目。If you specify an OS Loader GUID, this option merges the loader object in the system template to produce a bootable entry.

下列範例會合併目前 BCD 存放區中指定的 GUID 可在新 BCD 存放區中識別的作業系統載入器:The following example merges the operating-system loader in the current BCD store that the specified GUID identifies in the new BCD store:

bcdboot c:\Windows /m {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

/addlast/addlast

選擇性。Optional. 指定應該最後新增的 Windows 開機管理程式韌體項目。Specifies that the Windows Boot Manager firmware entry should be added last. 預設行為是先新增該項目。The default behavior is to add it first. 無法搭配 /p 使用。Cannot be used with /p.

bcdboot C:\Windows /addlast

/p/p

選擇性。Optional. 指定現有的 Windows 開機管理程式韌體項目位置應保留在 UEFI 開機順序中。Specifies that the existing Windows Boot Manager firmware entry position should be preserved in the UEFI boot order. 如果項目不存在,則會在第一個位置新增項目。If entry does not exist, a new entry is added in the first position. 無法搭配 /addlast 使用。Cannot be used with /addlast.

根據預設,在升級期間,BCDBoot 會將 Windows 開機管理程式移至 UEFI 開機順序中的第一個項目。By default, during an upgrade BCDBoot moves the Windows Boot Manager to be the first entry in the UEFI boot order.

bcdboot C:\Windows /p
bcdboot C:\Windows /p /d

/d/d

選擇性。Optional. 在 Windows 開機管理程式的 {bootmgr} 物件中保留現有的預設作業系統項目。Preserves the existing default operating system entry in the {bootmgr} object in Windows Boot Manager.

bcdboot C:\Windows /d

/c/c

選擇性。Optional. 指定不得遷移任何現有的 BCD 元素。Specifies that any existing BCD elements should not be migrated.

Windows 10 的新功能:在升級期間,預設會保留 debugsettingsflightsigning 之類的 BCD 元素。New for Windows 10: By default, during an upgrade, BCD elements such as debugsettings or flightsigning are preserved.

bcdboot C:\Windows /c

修復系統磁碟分割Repair the system partition

如果系統磁碟分割已損毀,您可使用 BCDBoot 來重建系統磁碟分割檔案,其做法是使用 Windows 磁碟分割中這些檔案的新複本。If the system partition has been corrupted, you can use BCDBoot to recreate the system partition files by using new copies of these files from the Windows partition.

  1. 將您的電腦開機到命令列。Boot your PC to a command line. 例如,開機至 Windows 安裝磁碟並按 Shift+F10,或開機至 Windows PE (WinPE:建立可開機的 USB 磁碟機)。For example, boot to the Windows installation disk and press Shift+F10, or boot to Windows PE (WinPE: Create USB Bootable drive).

  2. 使用 Diskpart 來判斷哪個磁碟機代號包含您的 Windows 磁碟分割和系統磁碟分割 (diskpart, list vol, exit)。Use Diskpart to determine which drive letter contains your Windows partition and system partition (diskpart, list vol, exit).

  3. 選擇性:將系統磁碟分割格式化:format (drive letter of your system partition) /qOptional: Format your system partition: format (drive letter of your system partition) /q

  4. 新增 Windows 磁碟分割的開機項目:bcdboot D:\WindowsAdd a boot entry for your Windows partition: bcdboot D:\Windows

  5. 將電腦重新開機。Reboot the PC. Windows 應會出現。Windows should appear.

設定或修復雙系統開機電腦上的開機功能表Set up or repair the boot menu on a dual-boot PC

設定電腦來啟動一個以上的作業系統時,您有時可能會無法開機進入其中一個作業系統。When setting up a PC to boot more than one operating system, you may sometimes lose the ability to boot into one of the operating systems. BCDBoot 選項可讓您快速新增 Windows 作業系統的開機選項。The BCDBoot option allows you to quickly add boot options for a Windows-based operating system. 若要設定雙系統開機電腦:To set up a dual-boot PC:

  1. 安裝不同的硬碟,或為每個作業系統準備個別的磁碟分割。Install a separate hard drive or prepare a separate partition for each operating system.

  2. 安裝作業系統。Install the operating systems. 例如,如果您的電腦有 Windows 7,請將 Windows 10 安裝到另一個硬碟或磁碟分割上。For example, if your PC has Windows 7, install Windows 10 onto the other hard drive or partition.

  3. 將電腦重新開機。Reboot the PC. 開機功能表應會出現並列出兩個作業系統。The boot menus should appear with both operating systems listed.

    如果這兩個作業系統都未列出:If both operating systems aren't listed:

    1. 以 Windows 內部的系統管理員身分開啟命令列,或使用 Windows 安裝媒體開機至命令列並且按 Shift+F10,或開機至 Windows PE (WinPE:建立可開機的 USB 磁碟機)。Open a command line, either as an administrator from inside Windows, or by booting to a command line using the Windows installation media and pressing Shift+F10, or by booting to Windows PE (WinPE: Create USB Bootable drive).

    2. 新增 Windows 作業系統的開機選項。Add boot options for a Windows operating system.

      bcdboot D:\Windows
      
    3. 將電腦重新開機。Reboot the PC. 現在,開機功能表會顯示兩個功能表選項。Now, the boot menu will show both menu options.

疑難排解Troubleshooting

如需在具有 Windows XP 和更新 Windows 版本 (如 Windows 7) 的電腦上修復開機檔案的詳細資訊,請參閱 Microsoft 知識庫文章 2277998For information about repairing the boot files on a PC with Windows XP and a more recent version of Windows such as Windows 7, see the Microsoft Knowledge Base Article 2277998.

相關主題Related topics

擷取及套用 Windows、系統和復原磁碟分割Capture and Apply Windows, System, and Recovery Partitions

設定 BIOS/MBR 型硬碟磁碟分割Configure BIOS/MBR-Based Hard Drive Partitions

設定 UEFI/GPT 型硬碟磁碟分割Configure UEFI/GPT-Based Hard Drive Partitions

BCDeditBCDedit

Bootsect 命令列選項Bootsect Command-Line Options

Diskpart 命令列語法Diskpart Command line syntax