與之前的製作Winpe x86與x64二合一的開機選單 (3)作法有很大的不同,不同點在於要能希望能在Legacy與UEFI環境下都能進行winpe4.0/winpe5.0、x86/x64的多重開機,藉由以下的Batch file做到Legacy mode下,做到winpe4.0/winpe5.0、x86/x64開機選項。
::設定環境變數 set bcd_path=c:\test\bcd if exist %bcd_path% del /q %bcd_path% ::建立新的空白的BCD檔 bcdedit /createstore %bcd_path% ::Windows Boot Manager ::建立Winpe 4.0 x86 OSLoader 設定 for /f "tokens=1-3 delims={}" %%i in ('bcdedit /store %bcd_path% /create /d "啟動 WinPE 4.0 x86" /application osloader') do set guid486=%%j ::若 Create 成功,電腦會傳回 GUID 值 bcdedit /store %bcd_path% /set {%guid486%} device ramdisk=[boot]\sources\winpe4_x86.wim,{ramdiskoptions} bcdedit /store %bcd_path% /set {%guid486%} osdevice ramdisk=[boot]\sources\winpe4_x86.wim,{ramdiskoptions} bcdedit /store %bcd_path% /set {%guid486%} locale zh-tw bcdedit /store %bcd_path% /set {%guid486%} path \windows\system32\boot\winload.exe bcdedit /store %bcd_path% /set {%guid486%} systemroot \windows bcdedit /store %bcd_path% /set {%guid486%} detecthal Yes bcdedit /store %bcd_path% /set {%guid486%} winpe Yes bcdedit /store %bcd_path% /set {%guid486%} ems No ::如果設定為Yes,則EMS設定中的bootems也要設定為Yes ::bcdedit /store %bcd_path% /set {bootmgr} default {%guid486%} ::將此項設為default boot ::建立Winpe 4.0 x64 OSLoader 設定 for /f "tokens=1-3 delims={}" %%i in ('bcdedit /store %bcd_path% /create /d "啟動 WinPE 4.0 x64" /application osloader') do set guid464=%%j bcdedit /store %bcd_path% /set {%guid464%} device ramdisk=[boot]\sources\winpe4_x64.wim,{ramdiskoptions} bcdedit /store %bcd_path% /set {%guid464%} osdevice ramdisk=[boot]\sources\winpe4_x64.wim,{ramdiskoptions} bcdedit /store %bcd_path% /set {%guid464%} locale zh-tw bcdedit /store %bcd_path% /set {%guid464%} path \windows\system32\boot\winload.exe bcdedit /store %bcd_path% /set {%guid464%} systemroot \windows bcdedit /store %bcd_path% /set {%guid464%} detecthal Yes bcdedit /store %bcd_path% /set {%guid464%} winpe Yes bcdedit /store %bcd_path% /set {%guid464%} ems No ::如果設定為Yes,則EMS設定中的bootems也要設定為Yes ::bcdedit /store %bcd_path% /set {bootmgr} default {%guid464%} ::將此項設為default boot ::建立Winpe 5.0 x86 OSLoader 設定 for /f "tokens=1-3 delims={}" %%i in ('bcdedit /store %bcd_path% /create /d "啟動 WinPE 5.0 x86" /application osloader') do set guid586=%%j bcdedit /store %bcd_path% /set {%guid586%} device ramdisk=[boot]\sources\winpe5_x86.wim,{ramdiskoptions} bcdedit /store %bcd_path% /set {%guid586%} osdevice ramdisk=[boot]\sources\winpe5_x86.wim,{ramdiskoptions} bcdedit /store %bcd_path% /set {%guid586%} locale zh-tw bcdedit /store %bcd_path% /set {%guid586%} path \windows\system32\boot\winload.exe bcdedit /store %bcd_path% /set {%guid586%} systemroot \windows bcdedit /store %bcd_path% /set {%guid586%} detecthal Yes bcdedit /store %bcd_path% /set {%guid586%} winpe Yes bcdedit /store %bcd_path% /set {%guid586%} ems No ::如果設定為Yes,則EMS設定中的bootems也要設定為Yes ::bcdedit /store %bcd_path% /set {bootmgr} default {%guid586%} ::將此項設為default boot ::建立Winpe 5.0 x64 OSLoader 設定 for /f "tokens=1-3 delims={}" %%i in ('bcdedit /store %bcd_path% /create /d "啟動 WinPE 5.0 x64" /application osloader') do set guid564=%%j bcdedit /store %bcd_path% /set {%guid564%} device ramdisk=[boot]\sources\winpe5_x64.wim,{ramdiskoptions} bcdedit /store %bcd_path% /set {%guid564%} osdevice ramdisk=[boot]\sources\winpe5_x64.wim,{ramdiskoptions} bcdedit /store %bcd_path% /set {%guid564%} locale zh-tw bcdedit /store %bcd_path% /set {%guid564%} path \windows\system32\boot\winload.exe bcdedit /store %bcd_path% /set {%guid564%} systemroot \windows bcdedit /store %bcd_path% /set {%guid564%} detecthal Yes bcdedit /store %bcd_path% /set {%guid564%} winpe Yes bcdedit /store %bcd_path% /set {%guid564%} ems No ::如果設定為Yes,則EMS設定中的bootems也要設定為Yes ::bcdedit /store %bcd_path% /set {bootmgr} default {%guid564%} ::將此項設為default boot ::建立 BOOTMGR 設定 bcdedit /store %bcd_path% /create {bootmgr} bcdedit /store %bcd_path% /set {bootmgr} description "Windows Boot Manager" bcdedit /store %bcd_path% /set {bootmgr} locale zh-tw bcdedit /store %bcd_path% /set {bootmgr} inherit {globalsettings} bcdedit /store %bcd_path% /set {bootmgr} bootdebug Yes bcdedit /store %bcd_path% /set {bootmgr} toolsdisplayorder {memdiag} bcdedit /store %bcd_path% /set {bootmgr} timeout 20 ::bcdedit /store %bcd_path% /set {bootmgr} device boot ::調整開機順序(選用) ::bcdedit /store %bcd_path% /set {bootmgr} displayorder {%guid486%} /addlast bcdedit /store %bcd_path% /set {bootmgr} displayorder {%guid486%} {%guid464%} {%guid586%} {%guid564%} ::Windows記憶體測試器 Bcdedit /store %bcd_path% /create {memdiag} Bcdedit /store %bcd_path% /set {memdiag} device boot Bcdedit /store %bcd_path% /set {memdiag} path \boot\memtest.exe bcdedit /store %bcd_path% /set {bootmgr} description "Windows Memory Diagnostic" Bcdedit /store %bcd_path% /set {memdiag} locale zh-tw Bcdedit /store %bcd_path% /set {memdiag} inherit {globalsettings} ::EMS設定 Bcdedit /store %bcd_path% /create {emssettings} Bcdedit /store %bcd_path% /set {emssettings} bootems No ::如果設定為Yes,則Windows Boot Manager中的ems也要設定為Yes ::偵測工具設定(選用) Bcdedit /store %bcd_path% /create {dbgsettings} Bcdedit /store %bcd_path% /set {dbgsettings} debugtype Serial Bcdedit /store %bcd_path% /set {dbgsettings} debugport 1 Bcdedit /store %bcd_path% /set {dbgsettings} baudrate 115200 ::通用設定 Bcdedit /store %bcd_path% /create {globalsettings} Bcdedit /store %bcd_path% /set {globalsettings} inherit {dbgsettings} {emssettings} ::Bcdedit /store %bcd_path% /set {globalsettings} locale zh-tw ::開機載入設定 Bcdedit /store %bcd_path% /create {bootloadersettings} Bcdedit /store %bcd_path% /set {bootloadersettings} inherit {globalsettings} {hypervisorsettings} ::bcdedit /store %bcd_path% /set {bootloadersettings} locale zh-tw ::Hypervisor設定 Bcdedit /store %bcd_path% /create {hypervisorsettings} bcdedit /store %bcd_path% /set {hypervisorsettings} description "Hypervisor Settings" Bcdedit /store %bcd_path% /set {hypervisorsettings} hypervisordebugtype Serial Bcdedit /store %bcd_path% /set {hypervisorsettings} hypervisordebugport 1 Bcdedit /store %bcd_path% /set {hypervisorsettings} hypervisorbaudrate 115200 ::建立 RAMDISK 設定 bcdedit /store %bcd_path% /create {ramdiskoptions} bcdedit /store %bcd_path% /set {ramdiskoptions} ramdisksdidevice boot bcdedit /store %bcd_path% /set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi ::bcdedit /store %bcd_path% /create {ramdiskoptions} /d "Ramdisk options" ::如要製作多重開機選單,千萬不要添加/d "Ramdisk options",不然看不到開機選單名稱 ::顯示BCD全部的設定 bcdedit /store %bcd_path% /enum all