|
最近想搞一下安装PE到VISTA的程式,本想用NTLDR+BOOT。INI但想到不方便,所以想到了OSLOADER:下面是一个大大用CMD为VISTA添加GRUB的选项,其中用到了BCDEDIT。大家看看,希望能直接移植到PE的安装
@echo off
rem by lianjiang
COLOR f9
set vid=
set timeout=5
set gname=GRUB for DOS
set gname2=\grldr.mbr
Set TIT=在Vista启动项中安装与卸载grub4dos项目的批处理 by lianjiang
TITLE %TIT%
bcdedit >temp_bcd.txt
type temp_bcd.txt | find "Windows Boot Manager" >nul && goto bcd_1
del temp_bcd.txt >nul 2>nul
cls
echo.
echo 请以管理员身份运行。
echo.
pause
:bcd_1
type temp_bcd.txt | find "%gname2%" >nul && goto un_bcd
bcdedit /create /d "%gname%" /application bootsector >vid.ini
for,/f,"tokens=2 delims={",%%i,In (vid.ini) Do (
set vida=%%i
)
for,/f,"tokens=1 delims=}",%%i,In ("%vida%") Do (
set vid={%%i}
)
echo %vid%>vid.ini
bcdedit /set %vid% device partition=%systemdrive% >nul
bcdedit /set %vid% path %gname2% >nul
bcdedit /displayorder %vid% /addlast >nul
bcdedit /timeout %timeout% >nul
if exist grldr.mbr (
copy grldr.mbr %systemdrive%\ /y
goto exit
) else (
echo.
echo 稍后请自行把grldr.mbr拷贝到%systemdrive%\根目录
echo.
PING/n 5 127.1>NUL
Goto exit
)
:un_bcd
cls
echo.
echo Vista的BCD启动项中存在grub4dos的项目["%gname2%"]。
echo ==============================================
echo.
set un_bcd=
Set /P un_bcd= 是否需要卸载grub4dos项目 ?[y/是 n/否]:
If %un_bcd%#==y# goto un_bcd_1
Goto exit
:un_bcd_1
for /f "tokens=1 delims=:" %%i In ('findstr /n %gname2% temp_bcd.txt') Do (
Set nid=%%i
)
set /a nid=%nid%-2
findstr /n identifier temp_bcd.txt>temp_bcd1.txt
for /f "tokens=2" %%i In ('findstr /n %nid%:identifier temp_bcd1.txt') Do (
echo %%i>vid.ini
)
for,/f,"tokens=1",%%i,In (vid.ini) Do (
set vid=%%i
)
bcdedit /delete %vid% /cleanup >nul
bcdedit /timeout %timeout% >nul
bcdedit >temp_bcd.txt
type temp_bcd.txt | find "%gname2%" >nul && goto un_bcd
if exist %systemdrive%\grldr.mbr (
attrib -h -s -r %systemdrive%\grldr.mbr >nul
del %systemdrive%\grldr.mbr >nul
)
:exit
del temp_bcd.txt >nul 2>nul
del temp_bcd1.txt >nul 2>nul
del vid.ini >nul 2>nul
[ 本帖最后由 uepon 于 2008-2-7 02:01 PM 编辑 ] |
|