Bcdedit命令使用實例

Windows啓動配置數據存儲編輯器Bcdedit使用實例  

2013-04-11 21:46:52  轉自:http://zhanqiguang.blog.163.com/blog/static/46507962201331191949366/

一、標識符

每一個bcdedit中的啓動項都有一個唯一的標識符,標識符可以唯一標識存儲中包含的項。標識符采取全局唯一標識符的形式,或稱GUID。GUID 具有以下格式,其中每個“x”代表一個十六進制數,{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}。如 {791d518d-3526-11de-8dab-b4cd0d61d150}。

幾個特殊的標識符:
{default}                      與啓動管理器默認應用程序項對應的虛擬標識符
{ntldr}                          基於NTLDR啓動的啓動項(早於VISTA的系統如XP)
{legacy}                      指存在上一代 Windows 系統如 Windows XP 的硬盤或分區
{current}                      當前運行的操作系統的操作系統啓動項對應的虛擬標識符
{bootmgr}                    windows啓動管理器項
{memdiag}                  內存診斷應用程序項
{ramdiskoptions}        包含啓動管理器所需的其他的RAM 磁盤設備選項


二、列出啓動項
命令格式:bcdedit /store /enum 應用程序名 [/v]。
bcdedit /store c:\boot\bcd /enum active #這裏的active是顯示啓動菜單上有的項目,all是顯示所有項目。
bcdedit /store c:\boot\bcd /enum active /v #這裏可選v參數,將以完整標識符(就是一長串的那種)代替顯示原有的{default}、{ntldr}等特殊標識符
bcdedit  #查看當前系統的啓動項 上面的命令在當前系統上的縮寫
以下命令針對當前系統,如果是其他BCD文件請添加完整的BCD文件路徑。


三、創建和修改啓動項
1、創建啓動項:bcdedit /create 標識符 /d "描述
                          bcdedit /create /d "描述"  /application 應用程序類型    #“應用程序類型”,創建非XP類型的啓動項時才需要。常用的有兩種:osloader(操作系統加載器)和bootsector(啓動扇區)。
2、複製啓動項:bcdedit /copy 要複製的標識符 /d "描述"
3、刪除啓動項:bcdedit /delete 標識符
                          bcdedit /delete {ntldr} /f    #刪除XP的啓動項時,應加上/f參數,如
4、設置啓動菜單顯示時間:bcdedit /timeout 數值(秒數)
5、設置啓動項顯示順序:bcdedit /displayorder 標識符1 標識符2 標識符n
                                        bcdedit /displayorder 標識符 /addlast      #顯示在最後面
                                        bcdedit /displayorder 標識符 /addfirst      #顯示在最前面
6、設定啓動菜單工具顯示順序:bcdedit /toolsdisplayorder 標識符
7、設置默認啓動項:
bcdedit /default 標識符


四、設置啓動項參數
設置參數:bcdedit /set 標識符 參數名 參數值      #如果不指定標識符,則默認爲當前系統,即{current}。
刪除參數:bcdedit /deletevalue  標識符 參數名
幾個重要參數:
device                    啓動設備,如partition=C:(分區)、vhd=[C:]\win8.vhd(虛擬磁盤)
path                       啓動文件路徑,如\ntldr(XP)、\Windows\system32\winload.exe(VISTA以上)
description             啓動菜單裏顯示的文字描述
locale                     區域設置,如zh-CN
osdevice               系統啓動設備,一般設成和device一樣(VISTA以上纔有效)
systemroot            系統根目錄,如\windows(VISTA以上有效)
inherit                    繼承項,如{bootloadersettings} (引導程序設置)、 {globalsettings}(全局設置)
ems                        啓用或禁用操作系統項的緊急管理服務
winpe                     是否windows PE,如Yes(只有是PE時才需要此參數)
detecthal                檢測HAL(硬件抽象層),如Yes(一般用於PE)
displayorder          顯示順序
toolsdisplayorder  工具顯示順序
time                       等待時間
win7 & win2008R2以上系統多出下面幾個參數
recoverysequence  恢復序列,一般與啓動項的標識符相同,如{255f2870-8c47-11e1-9764-f50784d59432}
recoveryenabled    啓用恢復,Yes爲啓用,No爲禁用
resumeobject          恢復對象,一般與啓動項的標識符相同,如{255f2870-8c47-11e1-9764-f50784d59432}


五、備份恢復啓動配置數據文件
創建空白配置文件:bcdedit /createstore d:\data\bcd
備份配置文件:       bcdedit /export d:\data\bcd
恢復配置文件:       bcdedit /import d:\data\bcd

命令舉例:
1、添加Windows XP啓動菜單
bcdedit /create {ntldr} /d "Windows XP
bcdedit /set {ntldr} device partition=D:
bcdedit /set {ntldr} path \ntldr
bcdedit /set {ntldr} inherit {bootloadersettings}
bcdedit /set {ntldr} locale zh-CN 
bcdedit /displayorder {ntldr} /addfirst


2、添加Windows 7啓動菜單
bcdedit /create /d "Windwos 7 旗艦版"  /application osloader
#這條命令完後會返回一個GUID值,如 {255f2870-8c47-11e1-9764-f50784d59432}
bcdedit /set {255f2870-8c47-11e1-9764-f50784d59432} device partition=E:
bcdedit /set {255f2870-8c47-11e1-9764-f50784d59432} path \windows\system32\winload.exe
bcdedit /set {255f2870-8c47-11e1-9764-f50784d59432} osdevice partition=E:
bcdedit /set {255f2870-8c47-11e1-9764-f50784d59432} systemroot \windows
bcdedit /set {255f2870-8c47-11e1-9764-f50784d59432} inherit {bootloadersettings}
bcdedit /set {255f2870-8c47-11e1-9764-f50784d59432} locale zh-CN
bcdedit /displayorder {255f2870-8c47-11e1-9764-f50784d59432} /addlast


3、添加wim映像(windows PE)啓動菜單
bcdedit /create {ramdiskoptions} 
bcdedit /set {ramdiskoptions} ramdisksdidevice partition=C:
bcdedit /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
#以上命令是先在 BCD 存儲中創建 {ramdisktoptions} 對象,其中partition=C:表示wim映像所在的分區
bcdedit /create /d "啓動 Windows PE" /application osloader
#這條命令完後會返回一個GUID值,如{b4323e91-a380-11e2-b02c-005056c00008}
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} device ramdisk=[C:]\boot\winpe.wim,{ramdiskoptions}
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} path \windows\system32\winload.exe
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} osdevice ramdisk=[C:]\boot\winpe.wim,{ramdiskoptions}  
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} systemroot \windows
#以下命令是啓動到 Windows 預安裝環境 (Windows PE)所需
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} winpe Yes
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} detecthal Yes
#以上命令是啓動到 Windows 預安裝環境 (Windows PE)所需
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} inherit {bootloadersettings}
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} locale zh-CN
bcdedit /set {b4323e91-a380-11e2-b02c-005056c00008} ems Yes
bcdedit /displayorder {b4323e91-a380-11e2-b02c-005056c00008} /addlast


4、添加內存診斷啓動項
bcdedit /create {memdiag} /d "Windows 內存診斷"
bcdedit /set {memdiag} device partition=C:
bcdedit /set {memdiag} path \boot\memtest.exe
bcdedit /set {memdiag} locale zh-CN
bcdedit /set {memdiag} /addlast


5、顯示win7和win2008r2以上系統隱藏的“Windows Recovery Environment ”菜單
bcdedit /displayorder  {255f2870-8c47-11e1-9764-f50784d59432} /addfirst
bcdedit


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章