Windows 7 使用也很久了, 之前為了搭配 XPE 的備份使用, 有研究了一下 BCDEdit 的指令, 但用過後, 久沒有使用又遺忘了, 剛好最近在製作快速安裝批次, 所以就順便在找了一下相關的資料, 並將做好的批次貼上來提供存檔^^"
批次檔內容
=================================================================
@Echo off
Color 0a
Mode con cols=48 lines=9
Set UD=100/07/08 By Shyam
Set BCDNAME=啟動 XPE 系統...By Shyam on %date:~0,10%
Set GPATH=\grldr.mbr
Set TIMEOUT=8
:CreateBCD
Echo 檢查是否為系統管理員...
Bcdedit > check_bcd.txt
Type check_bcd.txt | find "Windows Boot Manager" && Goto StartBCD
Del check_bcd.txt 2>nul
Echo.
Echo.
Echo. 請以系統管理者身份執行....
Echo.
Echo.
Goto End
:StartBCD
Type check_bcd.txt | find "%BCDNAME%" && Goto Un_BCD
Bcdedit /create /d "%BCDNAME%" /application bootsector > vid.1
For /f "tokens=2 delims={" %%i in (vid.1) Do Echo %%i > vid.2
For /f "tokens=1 delims=}" %%i in (vid.2) Do Set VID={%%i}
Del vid.*
Bcdedit /set %VID% device partition=%systemdrive%
Bcdedit /set %VID% path %GPATH%
Bcdedit /displayorder %VID% /addlast
Bcdedit /timeout %TIMEOUT%
Goto CreatBootFiles
:Un_BCD
Echo.
Echo 偵測到已安裝 開機選單...系統自動移除中...
Echo.
For /f "tokens=1 delims=:" %%i in ('findstr /n /c:"%BCDNAME%" check_bcd.txt') Do Set VID=%%i
Set /a VID=%VID%-3
Findstr /n ident check_bcd.txt > check_bcd.1
For /f "tokens=2 delims= " %%i in ('findstr /n /c:"%VID%:ident" check_bcd.1') Do Set VID=%%i
Bcdedit /delete %VID% /cleanup
Bcdedit > check_bcd.txt
Type check_bcd.txt | find "%BCDNAME%" && Goto Un_BCD
Del check_bcd.*
Goto End
:CreatBootFiles
Attrib -r -s -h %systemdrive%\menu.lst
Echo find --set-root /rxpe.bin >> %systemdrive%\menu.lst && Echo chainloader /rxpe.bin >> %systemdrive%\menu.lst
Attrib +r +s +h %systemdrive%\menu.lst
Attrib -r -s -h %systemdrive%\grldr
xCopy /h /y ..\grldr %systemdrive%\
xCopy /h /y ..\grldr.mbr %systemdrive%\
Attrib +r +s +h %systemdrive%\grldr
Attrib -r -s -h %systemdrive%\RXPE.*
xCopy /h /y ..\rxpe.COM %systemdrive%\
xCopy /h /y ..\RXPE.IM_ %systemdrive%\
xCopy /h /y ..\RXPE.SIF %systemdrive%\
xCopy /h /y ..\RXPE.BIN %systemdrive%\
Attrib +r +s +h %systemdrive%\RXPE.*
:End
=================================================================
參考資料:
http://technet.microsoft.com/zh-tw/library/cc709667%28WS.10%29.aspx
http://blog.sina.com.cn/s/blog_67278a3e0100n2px.html (此批次有錯, 直接執行會有錯誤)
沒有留言:
張貼留言