windows 2000/xp/2003/vista的启动项中安装/卸载grub4dos的脚本
说明:
1,以下安装/卸载脚本,简化自本人的“GGhost一键恢复2008”。
2,支持windows 2000/xp/2003/vista。支持任意语种的系统。
3,启动项中显示名称为“Start Grub4DOS”,延时3秒,请自行修改。
4,去掉了所有文件的复制,请自行复制grldr.mbr和grldr及其它所需文件。
5, windows 2000/xp/2003下使用了第三方工具inifile.exe。(要求放到d:\ggho下)
(需要的可从网盘下载:
http://lianjiang2004.ys168.com/)
本人不善长批处理,所示脚本,仅供参考。
http://gghost.uu1001.com/
=============================
@Echo Off
if not %os%.==Windows_NT. goto not_nt
cls
mode con: cols=76 lines=26
Set TT=安装程序 by lianjiang
COLOR f9
TITLE %TT%
set gname=Start Grub4DOS
set gname2=\grldr.mbr
set winver=
set ggpath6=
set ggpath0=d:\ggho
set vid=
set timeout=3
ver|find /i " 5.1">nul &&set winver=winnt&&goto sub_001
ver|find /i " 6.0">nul &&set winver=vista&&goto sub_003
ver|find /i " 5.0">nul &&set winver=winnt&&goto sub_001
ver|find /i " 5.2">nul &&set winver=winnt&&goto sub_001
:not_nt
cls
echo.
echo 很抱歉,本软件不能使用于非Windows 2k/xp/2k3/vista环境。
PING/n 5 127.1>NUL
Goto Exit
:sub_001
set ggpath6=
for %%B in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) do (
if exist %%B\boot.ini set ggpath6=%%B&&goto inst
)
goto inst
:sub_003
set ggpath6=%systemdrive%
:inst
if not %winver%#==winnt# goto vista_1
:winnt_1
attrib %ggpath6%\boot.ini -r -h -s >nul
if not exist %ggpath6%\g_boot.ini Copy %ggpath6%\boot.ini %ggpath6%\g_boot.ini /y >nul
%ggpath0%\inifile %ggpath6%\boot.ini timeout=%timeout% >nul
%ggpath0%\inifile %ggpath6%\boot.ini %ggpath6%%gname2%="%gname%" >nul
attrib %ggpath6%\boot.ini +r +h +s >nul
attrib %ggpath6%\g_boot.ini +r +h +s >nul
goto exit
:vista_1
if not exist %ggpath0%\nul md %ggpath0% >nul
bcdedit >%ggpath0%\temp_bcd.txt
type %ggpath0%\temp_bcd.txt | find "%gname%" >nul && goto vista_bcd
bcdedit /export "%ggpath0%\Bcd_Backup" >nul
bcdedit /create /d "%gname%" /application bootsector >%ggpath0%\vid.ini
for,/f,"tokens=2 delims={",%%i,In (%ggpath0%\vid.ini) Do (
set vida=%%i
)
for,/f,"tokens=1 delims=}",%%i,In ("%vida%") Do (
set vid={%%i}
)
echo %vid%>%ggpath0%\vid.ini
bcdedit /set %vid% device partition=%ggpath6% >nul
bcdedit /set %vid% path %gname2% >nul
bcdedit /displayorder %vid% /addlast >nul
:vista_bcd
bcdedit /timeout %timeout% >nul
:exit
cls
echo.
echo 安装完成。
echo.
echo 请自行复制grldr.mbr和grldr到%ggpath6%
Echo.
PING/n 3 127.1>NUL
=============================
@Echo Off
if not %os%.==Windows_NT. goto not_nt
cls
mode con: cols=76 lines=26
Set TT=卸载程序 by lianjiang
COLOR f9
TITLE %TT%
set winver=
set ggpath6=
set ggpath0=d:\ggho
set vid=
set timeout=3
ver|find /i " 5.1">nul &&set winver=winnt&&goto sub_001
ver|find /i " 6.0">nul &&set winver=vista&&goto sub_003
ver|find /i " 5.0">nul &&set winver=winnt&&goto sub_001
ver|find /i " 5.2">nul &&set winver=winnt&&goto sub_001
:not_nt
cls
echo.
echo 很抱歉,本软件不能使用于非Windows 2k/xp/2k3/vista环境。
PING/n 5 127.1>NUL
Goto Exit
:sub_001
set ggpath6=
for %%B in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) do (
if exist %%B\boot.ini set ggpath6=%%B&&goto uninst_01
)
goto uninst_01
:sub_003
set ggpath6=%systemdrive%
:uninst_01
if not %winver%#==winnt# goto uninst_4
for,/f,"tokens=1",%%i,In (%ggpath0%\vid.ini) Do (
set vid=%%i
)
bcdedit /delete %vid% /cleanup >nul
bcdedit /timeout %timeout% >nul
goto uninst_4a
:uninst_4
attrib -h -r -s %ggpath6%\boot.ini >nul
if exist %ggpath6%\boot.ggh attrib -h -r -s %ggpath6%\boot.ggh >nul&&del %ggpath6%\boot.ggh >nul
ren %ggpath6%\boot.ini boot.ggh >nul
findstr /b /i /v /c:"%ggpath6%\grldr" %ggpath6%\boot.ggh>%ggpath6%\boot.ini
bootcfg /timeout %timeout% >nul
attrib +h +r +s %ggpath6%\boot.ini >nul
del %ggpath6%\boot.ggh >nul
if exist %ggpath6%\g_boot.ini attrib %ggpath6%\g_boot.ini -r -h -s >nul&&del %ggpath6%\g_boot.ini >nul
:uninst_4a
cls
echo.
echo 卸载完成。
Echo.
PING/n 3 127.1>NUL