BCD:使用 {ramdiskoptions} 子句命名多個 WinPE

BCD:使用 {ramdiskoptions} 子句命名多個 WinPE

我想要一個包含多個 WinPE 版本的 BCD 啟動選單,並顯示其描述。我製作了一個拇指驅動器,後來又製作了 PXE,支援啟動到多個 WinPE 環境 - 從版本 3.1 到 10、x64 和 x32。問題是,當建立 BCD 儲存體以引導到 PE 時,您必須使用 {ramdiskoptions} 子句。在這種情況下,啟動時,選單不會顯示每個項目的「描述」 - 它僅顯示 {ramdiskoptions} 條目的描述,因此我最終得到了多個名為「Ramdisk Options」的選項。我將演示我是如何做到這一點的(假設%STR%是 BCD 儲存的完整路徑,並且 %GUID% 在下面的範例中進行了解釋):

1) bcdedit /createstore %STR%
2) bcdedit /store %STR% /create {ramdiskoptions} /d "Ramdisk Options"
3) bcdedit /store %STR% /set {ramdiskoptions} ramdisksdidevice Boot
4) bcdedit /store %STR% /set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi
5) bcdedit /store %STR% /create /d "WinPE x86 3.1" /application osloader
6) bcdedit /store %STR% /set %GUID% systemroot \Windows
7) bcdedit /store %STR% /set %GUID% detecthal Yes
8) bcdedit /store %STR% /set %GUID% winpe Yes
9) bcdedit /store %STR% /set %GUID% osdevice ramdisk=[boot]\Boot\winpex86-31.wim,{ramdiskoptions}
10) bcdedit /store %STR% /set %GUID% device ramdisk=[boot]\Boot\winpex86-31.wim,{ramdiskoptions}
11) (repeat lines 5 to 10 as needed)
12) bcdedit /store %STR% /create {bootmgr} /d "Windows Boot Manager"
13) bcdedit /store %STR% /set {bootmgr} displayorder %GUID% ........

因此,我對 WinPE v5 x86、v3.1 x64、v5 x64 和 v10 重複第 5 行到第 10 行。每次我在第 5 行設定新的描述,取得新的 %GUID%,在第 9 行和第 10 行設定適當的影像,最後我對每個剛剛建立的 %GUID% 進行顯示順序。然後我啟動驅動器,上面寫著:

Ramdisk Options
Ramdisk Options
Ramdisk Options
Ramdisk Options
Ramdisk Options

我希望它顯示每個條目的描述,例如WinPE x86 3.1.請告知我可能做錯了什麼。我也嘗試過使用easy-bcd來修改條目,但沒有成功。

編輯

又做了一些修改,我創建了另一個商店並在那裡只創建了 {ramdiskoptions} 。我發出了兩個命令,這是它們的輸出(僅顯示 ID 和類型):

d:\!@>bcdedit /store %str% /enum all /V
Setup Ramdisk Options
---------------------
identifier              {ae5534e0-a924-466c-b836-758539a3ee3a}
d:\!@>bcdedit /store %str% /enum all
Setup Ramdisk Options
---------------------
identifier              {ramdiskoptions}

所以我認為,這一切都歸結為創建另一個“Setup Ramdisk Options”類型的條目,但我在 bcdeditor 的幫助中找不到正確的命令。順便說一句,Visual BCD 會產生有關外部程式修改儲存的隨機錯誤,並且毫無用處。

答案1

看到這個文章。基本上,您可以定義多個 ramdisk 設備,而不是在一個 ramdisk 設備下擁有多個條目。

儘管只能建立一個 {ramdiskoptions} 對象,但可以透過以下解決方法使用與 {ramdiskoptions} ramdisksdipath 中指定的不同的 .sdi 檔案。目前我還沒有發現實現這一點的任何實際用途,但是,正如 cdob 指出的那樣,將來可能有必要。

bcdedit.exe /store C:\Boot\BCD /create /device

執行第一個指令將傳回全域唯一識別碼 (GUID) 值 - 例如 {e05b4c23-618a-11df-89c6-001d925a73cf}。在所有後續命令中,將 {ramdisk_guid} 替換為該值 -

bcdedit.exe /store C:\Boot\BCD /set {ramdisk_guid} ramdisksdidevice partition=C:

bcdedit.exe /store C:\Boot\BCD /set {ramdisk_guid} ramdisksdipath \Boot\different.sdi

現在使用它來啟動 WinPE -

bcdedit.exe /store C:\Boot\BCD /create /application osloader

執行此命令將傳回全域唯一識別碼 (GUID) 值 - 例如 {bdaf610c-622d-11df-a7ee-a711d7fae90e}。在所有後續命令中,將 {guid} 替換為該值,並將 {ramdisk_guid} 替換為透過執行步驟 1 中的命令建立的 GUID -

bcdedit.exe /store C:\Boot\BCD /set {guid} detecthal Yes
bcdedit.exe /store C:\Boot\BCD /set {guid} winpe Yes
bcdedit.exe /store C:\Boot\BCD /set {guid} osdevice ramdisk=[C:]\Sources\boot.wim,{ramdisk_guid}
bcdedit.exe /store C:\Boot\BCD /set {guid} device ramdisk=[C:]\Sources\boot.wim,{ramdisk_guid}
bcdedit.exe /store C:\Boot\BCD /set {guid} description "Windows PE"
bcdedit.exe /store C:\Boot\BCD /displayorder {guid} /addlast

答案2

Windows BCD 儲存體中的每個物件都有一個 GUID,可用於在適當的情況下連結該物件。

您可以使用可視化BCD編輯器為每個 wim 載入程式建立一個單獨的裝置選項物件。根據您的需求命名這些物件中的描述元素。

然後根據需要替換每個載入程式的每個應用程式裝置和作業系統裝置元素中對應的 GUID。

{ramdiskoptions} 只是一個具有預先定義固定 GUID 的裝置選項物件。

另請參閱 BCD 中的物件如何連結的說明Windows 7 VHD 啟動

答案3

由於存在錯誤,如果已設定 {ramdiskoptions} 描述,則任何後續基於 WinPE 的物件都不會顯示其自己的描述。

所以

2) bcdedit /store %STR% /create {ramdiskoptions} /d "Ramdisk Options"

應該改為

2) bcdedit /store %STR% /create {ramdiskoptions} 

這個小技巧完美解決了我所有基於Win8/Win10直到最新Win10 2004版的PE啟動管理器專案全部顯示為「Ramdisk選項」的問題。

這是一個範例腳本。

rem Creates BCD (boot configuration data) for three Windows PE 2.0 images or later
rem This script must be running in windows 7/8/10 and run as administrator
rem Or you can run it in the PE 2.or later environment
rem
Rem This script based on the Win10 Installation USB drive
Rem Put you PE wim file inside the \boot folder
Rem Put this script inside the \boot folder
Rem Modifi this script, change the description and the wim file name the match you wim file
Rem At last, run this script to generate BCD file.
Rem ** If you want to change the Boot menut of the UEFI boot, copy the new BCD file to \efi\microsoft\boot\ folder


set BCD-File=.\BCD
del %BCD-File%.bak
ren %BCD-File%  bcd.bak
pause
Bcdedit -createstore %BCD-File%
Bcdedit -store %BCD-File% -create {ramdiskoptions} 
Bcdedit -store %BCD-File% -set {ramdiskoptions} ramdisksdidevice  boot
Bcdedit -store %BCD-File% -set {ramdiskoptions} ramdisksdipath  \boot\boot.sdi


for /f "tokens=1-3" %%a in ('Bcdedit -store %BCD-File% -create /d "1. Win8PEx64 XiaoBai" /application osloader') do set guid4=%%c
Bcdedit -store %BCD-File% -set %guid4% systemroot \Windows
Bcdedit -store %BCD-File% -set %guid4% detecthal Yes
Bcdedit -store %BCD-File% -set %guid4% winpe Yes
Bcdedit -store %BCD-File% -set %guid4% osdevice ramdisk=[boot]\Boot\xiaobaiNT63PEX64.WIM,{ramdiskoptions} 
Bcdedit -store %BCD-File% -set %guid4% device ramdisk=[boot]\Boot\xiaobaiNT63PEX64.WIM,{ramdiskoptions}



for /f "tokens=1-3" %%a in ('Bcdedit -store %BCD-File% -create /d "2. Windows 10 x64 Installation" /application osloader') do set guid6=%%c
Bcdedit -store %BCD-File% -set %guid6% device ramdisk=[boot]\sources\boot.WIM,{ramdiskoptions} 
Bcdedit -store %BCD-File% -set %guid6% path \windows\system32\boot\winload.exe 
Bcdedit -store %BCD-File% -set %guid6% osdevice ramdisk=[boot]\sources\boot.WIM,{ramdiskoptions} 
Bcdedit -store %BCD-File% -set %guid6% systemroot \Windows
Bcdedit -store %BCD-File% -set %guid6% detecthal Yes
Bcdedit -store %BCD-File% -set %guid6% winpe Yes

Bcdedit -store %BCD-File% -create {bootmgr} /d "Windows PE Boot Manager"
Bcdedit -store %BCD-File% -set {bootmgr} timeout 10
Bcdedit -store %BCD-File% -set {bootmgr} displayorder %guid4%  %guid6%
Bcdedit -store %BCD-File% /enum all

相關內容