### From grub4dos Tutorial
1. grub4dos Beginner's Tutorial - Introductory Section
1.3 How to Install grub4dos?
1.3.4 Enter grub4dos through the Boot Menu of Windows VISTA/Window 7
Automatically load grub4dos into the Vista boot item (not MBR) using a batch script.
Loading grub4dos into the Vista boot item is relatively safer compared to loading it into the MBR.
【For Vista system, you cannot restore the MBR by fdisk /mbr, which will cause Vista to fail to boot.】
There are some introductions on the Internet about the manual method of loading grub4dos into the Vista boot item. Compared with modifying Boot.ini in WinXP, the operation is much more complicated.
The main thing is that an ID number [such as: b88a2da4-0a4e-11dc-813a-00e04c75ef59] needs to be generated during the operation, and it needs to be entered manually 3 times, which is really troublesome.
The following batch script automatically completes the entire loading operation.
Instructions:
1. When the batch script and grldr.mbr are in the same directory, the grldr.mbr file is automatically copied to the system root directory; otherwise, it needs to be copied manually.
2. After adding the grub4dos item in the boot item, copy the prepared menu.lst and grldr files to C:\ (can also be placed in the root directory of other partitions).
-------------------------------
Installation Batch Script
@echo off
rem by lianjiang
cls
echo.
echo Please run as an administrator.
echo.
pause
set gname=GRUB for DOS
set vid=
set timeout=5
bcdedit >bcdtemp.txt
type bcdtemp.txt | find "\grldr.mbr" >nul && echo. && echo There is already a grub4dos item in the BCD boot item, no need to install again.&& pause && goto exit
bcdedit /export "Bcd_Backup" >nul
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 \grldr.mbr >nul
bcdedit /displayorder %vid% /addlast >nul
bcdedit /timeout %timeout% >nul
if exist grldr.mbr copy grldr.mbr %systemdrive%\ /y && goto exit
echo.
echo Please copy grldr.mbr to the root directory of %systemdrive%\ later
echo.
pause
:exit
del bcdtemp.txt >nul
-------------------------------
Uninstallation Batch Script
@echo off
rem by lianjiang
cls
echo.
echo It is required that there is a temporary file automatically saved when the installation batch script is used for installation.
echo.
echo Please run as an administrator.
echo.
pause
set vid=
set timeout=5
if exist Bcd_Backup bcdedit /import "Bcd_Backup" >nul&& goto 1
if not exist vid.ini (
echo.
echo Because the relevant files are deleted, the boot item project cannot be deleted automatically, and it can only be deleted manually.
echo.
pause
goto exit
)
for /f "tokens=1" %%i In (vid.ini) Do (
set vid=%%i
)
bcdedit /delete %vid% /cleanup >nul
bcdedit /timeout %timeout% >nul
:1
del vid.ini >nul
if exist %systemdrive%\grldr.mbr (
attrib -h -s -r %systemdrive%\grldr.mbr >nul
del %systemdrive%\grldr.mbr >nul
)
:exit