|
原帖由 g12345 于 2011-1-9 20:47 发表
对不起,怪我没有说清楚,我的意思是将win7pe安装到windows7系统硬盘,并在系统启动菜单中加入win7pe启动项
引用“qj_tzy (虹桥电脑迷) ”大侠的作品,修改了下
@echo off
color 0a
echo 本脚本在启动盘\BOOT\下的BCD文件(若无,将自动重建BCD)中建立启动项。
echo 及WINPE3.0的WIM映像文件的启动项(文件名boot.wim,
echo 运行前先将它们拷入启动盘\boot目录下。并须将WIN7的Bootmgr及BOOT目录
echo (含BCD、boot.sdi、memtest.exe等文件)拷入启动盘根目录下;
ECHO 按^C中止本脚本运行,否则继续运行本脚本(批处理)。
pause
:drv
echo.
set /P DRV=请输入启动盘(含BOOT目录及以上文件)的盘符(如:D,不要冒号):
set bcddrv=%DRV%:
:is_bcdboot
set bcddir=/store %bcddrv%\boot\bcd
set hasbcd=有
if not EXIST %bcddrv%\boot\bcd set hasbcd=无&&goto init
echo.
echo 当前系统是否由当前BCD启动?
echo 提示:%bcddrv%\boot\下%hasbcd%bcd文件!
echo 一般地,由当前BCD启动的winvista/win7/win2008/win2008r2系统,
echo 对当前BCD有保护作用,以直接操作当前BCD方式添加启动项,但BCD不能删除重建;
echo 对WINXP/win2003/winpe2.x/winpe3.0系统,
echo 及非由当前BCD启动的winvista/win7/win2008/win2008r2系统,
echo 对当前BCD无保护作用,以备份方式操作当前BCD,该BCD可删除重建。
echo 若选错,将不能正常执行以下命令。但可关闭CMD窗口终止执行后,
echo 重新选另一项进行处理。
set isbcdboot=
set /P isbcdboot=请选择(是-直接回车;若-N或n等字母或数字键后回车):
IF "%isbcdboot%"=="" set bcddir=%isbcdboot%&&goto Win7
:initset
echo.
echo 当前系统不是由当前BCD启动,可对%bcddrv%\boot\bcd进行初始化(删除重建),
set wantempty=
set /P wantempty=(不初始化-直接回车;要初始化-Y或y等字母或数字键后回车):
IF "%wantempty%"=="" goto Win7
:init
if not EXIST %bcddrv%\boot\bcd echo 因%bcddrv%\boot\下%hasbcd%bcd文件,将直接重建%bcddrv%\boot\bcd!&& pause
echo on
if EXIST %bcddrv%\boot\bcd attrib -h -s -r %bcddrv%\boot\bcd.*&&del %bcddrv%\boot\bcd.* >nul
bcdedit /createstore %bcddrv%\boot\bcd
rem 建立bootmgr主入口....
bcdedit %bcddir% /create {bootmgr} /d "Windows Boot Manager"
rem 建立内存诊测程序项....
bcdedit %bcddir% /create {memdiag} /d "Windows memdiag"
bcdedit %bcddir% /toolsdisplayorder {memdiag} /addlast
:Win7
rem 建立winvista/win7/win2008系统启动项....
for /f "delims={,} tokens=2" %%a in ('bcdedit %bcddir% /create /d "Windows 7" /application osloader ') do set vsaid={%%a}
bcdedit %bcddir% /set %vsaid% device partition=%bcddrv%
bcdedit %bcddir% /set %vsaid% path \windows\system32\winload.exe
bcdedit %bcddir% /set %vsaid% locale zh-CN
bcdedit %bcddir% /set %vsaid% inherit {bootloadersettings}
bcdedit %bcddir% /set %vsaid% osdevice partition=%bcddrv%
bcdedit %bcddir% /set %vsaid% systemroot \windows
bcdedit %bcddir% /set %vsaid% nx optin
bcdedit %bcddir% /displayorder %vsaid% /addlast
:win7pe
rem 建立win7pe_wim开机菜单启动项....
bcdedit %bcddir% /create {ramdiskoptions} /d "win7pe"
bcdedit %bcddir% /set {ramdiskoptions} ramdisksdidevice partition=%bcddrv%
bcdedit %bcddir% /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi
rem BCD菜单建立"Windows7PE"项,只跟bcdtool查看有关,与开机菜单不是同一个东西
for /f "delims={,} tokens=2" %%a in ('bcdedit %bcddir% -create /d "Windows7PE" -application osloader ') do set w30id={%%a}
bcdedit %bcddir% -set %w30id% device ramdisk="[%bcddrv%]\boot\boot.wim,{ramdiskoptions}"
bcdedit %bcddir% -set %w30id% osdevice ramdisk="[%bcddrv%]\boot\boot.wim,{ramdiskoptions}"
bcdedit %bcddir% -set %w30id% path \windows\system32\boot\winload.exe
bcdedit %bcddir% -set %w30id% locale zh-CN
bcdedit %bcddir% -set %w30id% inherit {bootloadersettings}
bcdedit %bcddir% -set %w30id% systemroot \windows
bcdedit %bcddir% -set %w30id% detecthal yes
bcdedit %bcddir% -set %w30id% winpe yes
bcdedit %bcddir% -set %w30id% ems yes
bcdedit %bcddir% -displayorder %w30id% -addlast
:bootmgr
echo on
rem 设定主入口bootmgr的参数....
bcdedit %bcddir% /set {bootmgr} device partition=%bcddrv%
bcdedit %bcddir% /set {bootmgr} inherit {globalsettings}
bcdedit %bcddir% /set {bootmgr} locale "zh-CN"
bcdedit %bcddir% /timeout 2
rem 这里的%vsaid%、%w30id%代表开机菜单的顺序
bcdedit %bcddir% /displayorder %vsaid% %w30id%
bcdedit %bcddir% /default %vsaid%
:end
echo off
echo.
echo 所有操作结束!
echo 将调用bcdtool工具对BCD中的启动项设置进行增删修改等操作!
pause
bcdtool |
|