|
最近投入WIN7的怀抱,且开始研究PEY.X(Y=2、3)。因此想在win7 上启动PEY.X(Y=2、3)。苦于无理想的安装器,因此写了一个管用的批处理。它的作用就是在VISTA/2008/WIN7系统上,通过编辑BCD文件,加入BOOT.WIM和BOOT.SDI的引导。
上P:
安装
@echo off
COLOR f9
set vid=
set timeout=%~1
set gname=%~2
set gname2=boot\win7pe.wim
TITLE 设置绝对PE工具箱的BCD相关引导
:bcd_1
bcdedit >temp_bcd.txt
type temp_bcd.txt | find "%gname2%" >nul && goto un_bcd_1
bcdedit.exe /create -device > %windir%\SYSTEM32\win7ram.ini
for,/f,"tokens=2 delims={",%%i,In (%windir%\SYSTEM32\win7ram.ini) Do (
set vidb=%%i
)
for,/f,"tokens=1 delims=}",%%i,In ("%vidb%") Do (
set vidram={%%i}
)
echo %vidram%>%windir%\SYSTEM32\win7ram.ini
bcdedit.exe /set %vidram% ramdisksdidevice partition=%systemdrive% >nul
bcdedit.exe /set %vidram% ramdisksdipath \boot\win7pe.sdi >nul
bcdedit /create /d "%gname%" /application OSLOADER >%windir%\SYSTEM32\win7pe.ini
for,/f,"tokens=2 delims={",%%i,In (%windir%\SYSTEM32\win7pe.ini) Do (
set vida=%%i
)
for,/f,"tokens=1 delims=}",%%i,In ("%vida%") Do (
set vid={%%i}
)
echo %vid%>%windir%\SYSTEM32\win7pe.ini
bcdedit /set %vid% device "ramdisk=[%systemdrive%]\%gname2%,%vidram%" >nul
bcdedit /set %vid% path "\windows\system32\boot\winload.exe" >nul
bcdedit /set %vid% osdevice "ramdisk=[%systemdrive%]\%gname2%,%vidram%" >nul
bcdedit /set %vid% systemroot "\windows" >nul
bcdedit /set %vid% detecthal "YES" >nul
bcdedit /set %vid% winpe "YES" >nul
bcdedit /displayorder %vid% /addlast >nul
bcdedit /timeout %timeout% >nul
goto exit
:un_bcd_1
If Not Exist %windir%\SYSTEM32\win7pe.ini goto exit
for,/f,"tokens=1",%%i,In (%windir%\SYSTEM32\win7pe.ini) Do (
set vid=%%i
)
bcdedit /delete %vid% /cleanup >nul
del %windir%\SYSTEM32\win7pe.ini
for,/f,"tokens=1",%%i,In (%windir%\SYSTEM32\win7ram.ini) Do (
set vidram=%%i
)
bcdedit /delete %vidram% /cleanup >nul
del %windir%\SYSTEM32\win7ram.ini
goto bcd_1
:exit
del temp_bcd.txt
卸载
@echo off
COLOR f9
set vid=
set gname2=boot\win7pe.wim
TITLE 删除绝对PE工具箱的BCD相关引导
If Not Exist %windir%\SYSTEM32\win7pe.ini exit
for,/f,"tokens=1",%%i,In (%windir%\SYSTEM32\win7pe.ini) Do (
set vid=%%i
)
bcdedit /delete %vid% /cleanup >nul
If Not Exist %windir%\SYSTEM32\win7ram.ini exit
for,/f,"tokens=1",%%i,In (%windir%\SYSTEM32\win7ram.ini) Do (
set vidram=%%i
)
bcdedit /delete %vidram% /cleanup >nul
bcdedit /timeout 0 >nul
del %windir%\SYSTEM32\win7pe.ini
del %windir%\SYSTEM32\win7ram.ini
del %windir%\SYSTEM32\temp_bcd.txt
del %windir%\SYSTEM32\DELBOOT.CMD
为了方便卸载,在WINDOWS目录下面生成了win7pe.ini和win7ram.ini 用来存放卸载用的GUID。其中红色的部分,为BOOT.WIM和BOOT.SDI的位置。通过对这些文本的修改,可以把BOOT.WIM BOOT.SDI 随意放置(包括放到系统盘以外的分区)。
[ 本帖最后由 uepon 于 2010-12-23 18:18 编辑 ] |
|