最新消息

[公告2014/05/30] 如有需要將部落格中,任何一篇文章的程式碼使用在商業用途,請與我聯繫。

[公告2015/04/26] Line版的 iInfo程式與投資應用 群組已上線想加入的朋友們,請先查看 "入群須知" 再與我聯繫 Line : aminwhite5168,加入請告知身分與回答 "入群須知" 的問題。

[公告2018/04/22] 台北 Python + Excel VBA 金融資訊爬蟲課程,課程如網頁內容 金融資訊爬蟲班:台北班 Python 金融資訊爬蟲、EXCEL VBA 金融資訊爬蟲

[公告2019/01/08] 請注意:我再次重申,部落格文章的程式碼,是要提供各位參考與學習,一旦網頁改版請自行修改,別要求東要求西要我主動修改,你們用我寫東西賺錢了、交差了,請問有分我一杯羹嗎?既然賺錢沒分我,請問有什麼理由要求我修改,如果沒能力改,就花錢來找我上課。

[公告2019/12/01] 若各位有 Excel VBA 案子開發需求,歡迎與我聯繫,可接案處理。

[公告2020/05/22] 頁面載入速度慢,起因為部分JS來源(alexgorbatchev.com)失效導致頁面載入變慢,目前已做調整,請多見諒。

2014年2月27日 星期四

Legacy mode下,修改BCD檔設定winpe4.0/winpe5.0、x86/x64開機選單

最近想要做多重開機選單,花了點時間研究一下,順道記錄一下相關內容。
與之前的製作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