|
hnfeng
初级用户
 
积分 89
发帖 36
注册 2007-12-20
状态 离线
|
『楼 主』:
给 Vista 启动菜单添加 GRUB4DOS 项的批处理
使用 LLM 解释/回答一下
在 XP 下,直接修改 boot.ini 即可添加 GRUB4DOS 项,但是在 Vista 下就没那么简单。
因公司和家里的电脑都是 XP + Vista ,前几日多次试验 GURB4DOS 的功能。之前在 添加这个菜单项都是手工添加,今天做了个批处理,共享出来吧。为防止菜鸟...,前面加了一些垃圾。
下面的批处理将自动添加 GRUB4DOS 启动项到 Vista 的启动菜单中:
===== Add_GRUB4DOS_Menu.bat =====
@echo off
echo 该批处理自动往 Vista 系统的启动菜单中添加 GRUB4DOS 的启动项。
echo 如果不是单一的 Vista(还有XP,2K),必须在 Vista 下运行。
echo 另外,需以管理员身份运行。
echo .
pause
ver | find "6.0." > NUL && goto START
ver | find "XP" > NUL && goto XP2K
ver | find "2000" > NUL && goto XP2K
goto EXIT
:XP2K
echo 不能在 WinXP 或 Win2000 中运行该批处理。
goto EXIT
REM ============= 以上的内容纯属...... ==============
:START
cls
bcdedit | find "\grldr.mbr" > NUL && echo 启动项中已有grub4dos,无需重复安装。&& goto EXIT
bcdedit /create /d "Boot From GRUB4DOS" /application bootsector >GrubID.txt
rem 上面欲增加的GRUB菜单名,可以修改为"GRUB For DOS"、"DOS + GHOST" 等等
for /f "tokens=2" %%i in (GrubID.txt) do set GrubID=%%i
del GrubID.txt > NUL
bcdedit /set %GrubID% device partition=%SystemDrive%
bcdedit /set %GrubID% path \grldr.mbr
bcdedit /displayorder %GrubID% /addlast
echo .
echo 上面应出现 3 个“操作成功完成。”
echo .
echo 请自行复制 grldr.mbr 到 %SystemDrive%\
echo .
echo 请自行复制 grldr 到 C:\
echo .
echo 根据需要,请自行复制其他有关文件,如 menu.lst, fonts, memdisk.gz 及背景图片等文件到相应位置。
:EXIT
====== THE END =====
各人使用 GRUB4DOS 的方式可能各有不同,所以没有自动复制 grldr.mbr 等文件,还是自己复制感觉稳妥吧。
Last edited by hnfeng on 2008-1-30 at 01:09 PM ]
Under XP, you can directly modify boot.ini to add a GRUB4DOS entry, but it's not that simple under Vista.
Since both the company and home computers are XP + Vista, I experimented with GURB4DOS functions many times a few days ago. Previously, I added this menu item manually. Today, I made a batch script and share it. To prevent newbies..., I added some junk at the front.
The following batch script will automatically add the GRUB4DOS boot entry to the Vista boot menu:
===== Add_GRUB4DOS_Menu.bat =====
@echo off
echo This batch script automatically adds the GRUB4DOS boot entry to the Vista system's boot menu.
echo If it's not a single Vista (there are also XP, 2K), it must be run under Vista.
echo Also, it needs to be run as an administrator.
echo .
pause
ver | find "6.0." > NUL && goto START
ver | find "XP" > NUL && goto XP2K
ver | find "2000" > NUL && goto XP2K
goto EXIT
:XP2K
echo Cannot run this batch script in WinXP or Win2000.
goto EXIT
REM ============= The above content is purely...... ==============
:START
cls
bcdedit | find "\grldr.mbr" > NUL && echo There is already grub4dos in the boot entry, no need to install repeatedly.&& goto EXIT
bcdedit /create /d "Boot From GRUB4DOS" /application bootsector >GrubID.txt
rem The above GRUB menu name to be added can be modified to "GRUB For DOS", "DOS + GHOST", etc.
for /f "tokens=2" %%i in (GrubID.txt) do set GrubID=%%i
del GrubID.txt > NUL
bcdedit /set %GrubID% device partition=%SystemDrive%
bcdedit /set %GrubID% path \grldr.mbr
bcdedit /displayorder %GrubID% /addlast
echo .
echo The above should have 3 "Operation completed successfully."
echo .
echo Please copy grldr.mbr to %SystemDrive%\ by yourself
echo .
echo Please copy grldr to C:\ by yourself
echo .
echo According to needs, please copy other related files by yourself, such as menu.lst, fonts, memdisk.gz and background pictures, etc., to the corresponding positions.
:EXIT
====== THE END =====
Everyone may use GRUB4DOS in different ways, so there is no automatic copying of grldr.mbr and other files. It's still safer to copy them yourself.
Last edited by hnfeng on 2008-1-30 at 01:09 PM ]
|
|
2008-1-29 17:04 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
|
2008-1-29 17:16 |
|
|
hnfeng
初级用户
 
积分 89
发帖 36
注册 2007-12-20
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
一楼的批处理有个问题:删除这个菜单项时需要手工操作:
进入CMD, 运行 bcdedit,找到“实模式启动扇区”,复制其下面的“标识符”(包含大括号的那串字符),键入 bcdedit /delete 粘贴刚刚复制的内容,回车即可。
为了方便,我稍稍修改一下 Add_GRUB4DOS_Menu.bat,然后可以使用下面的 Del_GRUB4DOS_Menu.bat 自动删除 GRUB4DOS 启动项。
===== Add_GRUB4DOS_Menu.bat =====
@echo off
echo 该批处理自动往 Vista 系统的启动菜单中添加 GRUB4DOS 的启动项。
echo 如果不是单一的 Vista(还有XP,2K),必须在 Vista 下运行。
echo 另外,需以管理员身份运行。
echo .
pause
ver | find "6.0." > NUL && goto START
ver | find "XP" > NUL && goto XP2K
ver | find "2000" > NUL && goto XP2K
goto EXIT
:XP2K
echo 不能在 WinXP 或 Win2000 中运行该批处理。
goto EXIT
REM ============= 以上的内容纯属...... ==============
:START
cls
bcdedit | find "\grldr.mbr" > NUL && echo 启动项中已有grub4dos,无需重复安装。&& goto EXIT
bcdedit /create /d "Boot From GRUB4DOS" /application bootsector >%SystemRoot%\GrubID.txt
rem 上面欲增加的GRUB菜单名,可以修改为"GRUB For DOS"、"DOS + GHOST" 等等
for /f "tokens=2" %%i in (%SystemRoot%\GrubID.txt) do set GrubID=%%i
bcdedit /set %GrubID% device partition=%SystemDrive%
bcdedit /set %GrubID% path \grldr.mbr
bcdedit /displayorder %GrubID% /addlast
echo .
echo 上面应出现 3 个“操作成功完成。”
echo .
echo 请自行复制 grldr.mbr 到 %SystemDrive%\
echo .
echo 请自行复制 grldr 到 C:\
echo .
echo 根据需要,请自行复制其他有关文件,如 menu.lst, fonts, memdisk.gz 及背景图片等文件到相应位置。
:EXIT
====== THE END =====
===== Del_GRUB4DOS_Menu.bat =====
@echo off
bcdedit | find "\grldr.mbr" > NUL && goto START
echo 启动菜单中没找到 grub4dos 项。
goto EXIT
:START
cls
if not exist %SystemRoot%\GrubID.txt goto ERROR
for /f "tokens=2" %%i in (%SystemRoot%\GrubID.txt) do set GrubID=%%i
bcdedit /delete %GrubID%
Del %SystemRoot%\GrubID.txt > NUL
goto EXIT
:ERROR
echo 找不到 %SystemRoot%\GrubID.txt,不能自动删除。
:EXIT
====== THE END =====
Last edited by hnfeng on 2008-1-30 at 01:10 PM ]
There is a problem with the batch script in the first floor: when deleting this menu item, manual operation is required:
Enter CMD, run bcdedit, find "Real - mode boot sector", copy the "identifier" (the string containing curly braces) below it, type bcdedit /delete and paste the just - copied content, and press Enter.
For convenience, I slightly modify Add_GRUB4DOS_Menu.bat, and then can use the following Del_GRUB4DOS_Menu.bat to automatically delete the GRUB4DOS boot item.
===== Add_GRUB4DOS_Menu.bat =====
@echo off
echo This batch script automatically adds the boot item of GRUB4DOS to the boot menu of Vista system.
echo If it is not a single Vista (there are also XP, 2K), it must be run under Vista.
echo In addition, it needs to be run as an administrator.
echo .
pause
ver | find "6.0." > NUL && goto START
ver | find "XP" > NUL && goto XP2K
ver | find "2000" > NUL && goto XP2K
goto EXIT
:XP2K
echo This batch script cannot be run in WinXP or Win2000.
goto EXIT
REM ============= The above content is purely...... ==============
:START
cls
bcdedit | find "\grldr.mbr" > NUL && echo There is already grub4dos in the boot item, no need to install repeatedly.&& goto EXIT
bcdedit /create /d "Boot From GRUB4DOS" /application bootsector >%SystemRoot%\GrubID.txt
rem The above GRUB menu name to be added can be modified to "GRUB For DOS", "DOS + GHOST", etc.
for /f "tokens=2" %%i in (%SystemRoot%\GrubID.txt) do set GrubID=%%i
bcdedit /set %GrubID% device partition=%SystemDrive%
bcdedit /set %GrubID% path \grldr.mbr
bcdedit /displayorder %GrubID% /addlast
echo .
echo The above should have 3 "Operation completed successfully."
echo .
echo Please copy grldr.mbr to %SystemDrive%\ by yourself.
echo .
echo Please copy grldr to C:\ by yourself.
echo .
echo According to the need, please copy other relevant files, such as menu.lst, fonts, memdisk.gz and background pictures and other files to the corresponding positions.
:EXIT
====== THE END =====
===== Del_GRUB4DOS_Menu.bat =====
@echo off
bcdedit | find "\grldr.mbr" > NUL && goto START
echo The grub4dos item is not found in the boot menu.
goto EXIT
:START
cls
if not exist %SystemRoot%\GrubID.txt goto ERROR
for /f "tokens=2" %%i in (%SystemRoot%\GrubID.txt) do set GrubID=%%i
bcdedit /delete %GrubID%
Del %SystemRoot%\GrubID.txt > NUL
goto EXIT
:ERROR
echo %SystemRoot%\GrubID.txt is not found, and automatic deletion cannot be performed.
:EXIT
====== THE END =====
Last edited by hnfeng on 2008 - 1 - 30 at 01:10 PM ]
|
|
2008-1-29 17:57 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
既然是为了方便菜鸟,那么请人务必把相关工具给个链接!
我觉得你应该把这个批处理做一个通用性的XP 2003 VIST的
多启动菜单 (不包括LINUX)
要求如下:
自动识别该计算机有几个系统
在系统文件(boot)中写入相互启动的菜单
xp 2003 vist通用
不破坏原来的启动菜单
有安全的卸载功能
我想应该对于您来说不会很难吧!! 呵呵, 写好后
我会把此贴置顶一段时间。
Since it is for the convenience of beginners, please be sure to provide links to relevant tools!
I think you should make this batch processing a general XP 2003 VIST multi-boot menu (excluding LINUX)
The requirements are as follows:
- Automatically identify how many systems this computer has
- Write a mutually bootable menu in the system file (boot)
- General for XP 2003 VIST
- Do not damage the original boot menu
- Have a safe uninstall function
I think it shouldn't be difficult for you!! Hehe, after writing it, I will pin this post for a while.
|
|
2008-1-30 01:09 |
|
|
hnfeng
初级用户
 
积分 89
发帖 36
注册 2007-12-20
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
Originally posted by 429499381 at 2008-1-30 01:09 AM:
……
要求如下:
自动识别该计算机有几个系统
在系统文件(boot)中写入相互启动的菜单
xp 2003 vist通用
不破坏原来的启动菜单
有安全的卸载功能
...
第一个基本不用理会吧。下面三个问题也不大。
最后一条不好办,因为我暂时还不知道怎么删除文件里面的特定的行。
如果使用一个备份文件替换回来,那么在此期间对启动菜单所做的变动(如新安装系统或者手动修改)将全部消失,不妥不妥。
另外,好像没什么人对这个话题感兴趣。我还是不要继续瞎忙了。
Originally posted by 429499381 at 2008-1-30 01:09 AM:
……
The requirements are as follows:
Automatically identify how many systems this computer has
Write a mutually bootable menu in the system file (boot)
Universal for xp 2003 vist
Do not destroy the original boot menu
Have a safe uninstall function
...
The first one can basically be ignored. The following three are not a big deal.
The last one is difficult because I don't know how to delete specific lines in the file for the time being.
If a backup file is used to replace it, then all changes made to the boot menu during this period (such as newly installed systems or manual modifications) will all disappear, which is not appropriate.
Also, it seems that no one is interested in this topic. I'd better not continue to mess around.
|
|
2008-1-30 19:28 |
|
|
429499381
中级用户
  
积分 452
发帖 202
注册 2006-12-21
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
如果一点点事都要很多人感兴趣的话,恐怕会有很次失望。
为何你不证明一下你行, 为何不想办法让更多人对此话题感兴趣呢?
If every little thing requires a lot of people to be interested, I'm afraid there will be a lot of disappointment.
Why don't you prove that you can do it, why don't you find a way to make more people interested in this topic?
|
|
2008-2-20 00:41 |
|
|
zg888
初级用户
 
积分 37
发帖 17
注册 2007-1-27
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Originally posted by 429499381 at 2008-1-30 01:09 AM:
既然是为了方便菜鸟,那么请人务必把相关工具给个链接!
我觉得你应该把这个批处理做一个通用性的XP 2003 VIST的
多启动菜单 (不包括LINUX) ...
XP/2003用系统自带的bootcfg命令很好办
pushd %SystemDrive%\
set btini=boot.ini
attrib -s -h -r %btini%
FIND /I "c:\grldr" %btini%
::没有就添加一个启动项c:\grldr="grubdos"
IF "%ERRORLEVEL%"=="1" @echo.c:\grldr="grubdos">>%btini%
for /f "tokens=1,2* delims=: " %%i in ('bootcfg/query^|findstr /I /n "c:\grldr"') do set /a hang=%%i - 2
for /f "tokens=1-5 delims=: " %%i in ('bootcfg/query^| findstr /i /n "启动项目"') do if "%%i"=="%hang%" set qdid=%%l
bootcfg /Delete /ID %qdid%
pause
因为鄙人没有用过VISTA,固VISTA下就不知道了
Originally posted by 429499381 at 2008-1-30 01:09 AM:
Since it is for the convenience of beginners, then please be sure to provide a link to the relevant tools!
I think you should make this batch processing a universal multi-boot menu for XP 2003 VIST (excluding LINUX)...
For XP/2003, it's very easy with the system's own bootcfg command
pushd %SystemDrive%\
set btini=boot.ini
attrib -s -h -r %btini%
FIND /I "c:\grldr" %btini%
::If not, add a startup item c:\grldr="grubdos"
IF "%ERRORLEVEL%"=="1" @echo.c:\grldr="grubdos">>%btini%
for /f "tokens=1,2* delims=: " %%i in ('bootcfg/query^|findstr /I /n "c:\grldr"') do set /a hang=%%i - 2
for /f "tokens=1-5 delims=: " %%i in ('bootcfg/query^| findstr /i /n "Startup Item"') do if "%%i"=="%hang%" set qdid=%%l
bootcfg /Delete /ID %qdid%
pause
Because I have not used VISTA, so I don't know about VISTA
|
|
2008-4-20 16:06 |
|
|
yankaiqian
初级用户
 
积分 122
发帖 10
注册 2004-3-9
状态 离线
|
『第 8 楼』:
看到這個我才弄明白之前的一個事情
使用 LLM 解释/回答一下
多謝!
一兩周前我也想試著通過VISTA的引導管理器來引導grub for dos,然后在網上看到這個頁面介紹:
http://grub4dos.sourceforge.net/wiki/index.php/Grub4dos安装和启动
我當時就在vista下面執行了如下三個語句:
bcdedit /create /d "Start GRUB4DOS" /application bootsector
bcdedit /set {id} device boot
bcdedit /set {id} path \grldr.mbr
bcdedit /displayorder {id} /addlast
其中 {id} 我替換成了第一條命令的輸出內容,可是下面第二個命令后面的boot我沒有變,就照樣輸入進去。結果引導不了,當時還以為是grldr.mbr文件有問題了呢……
今天看到這個帖子,就將那個“boot”改為“partition=C:”就OK了!
Thanks!
A week or two ago, I also wanted to try to boot GRUB for DOS through the VISTA boot manager, and then saw this page introduction on the Internet:
http://grub4dos.sourceforge.net/wiki/index.php/Grub4dos安装和启动
I executed the following three statements under VISTA at that time:
bcdedit /create /d "Start GRUB4DOS" /application bootsector
bcdedit /set {id} device boot
bcdedit /set {id} path \grldr.mbr
bcdedit /displayorder {id} /addlast
Among them, {id} I replaced with the output content of the first command, but I did not change the boot after the second command, just entered it as it was. As a result, it could not be booted. I thought at that time that the grldr.mbr file was problematic...
Today, I saw this post and changed that "boot" to "partition=C:" and it worked!
|
|
2008-4-23 11:23 |
|
|
690712
初级用户
 
积分 32
发帖 16
注册 2007-1-25
状态 离线
|
|
2008-5-11 09:26 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
这几天正关心这个,正好复制回去好好学学,谢谢了。
--------------------------------------------------------------------------------------------------
看完想问个问题,比较菜,见谅。
以前 XP 时可以在 BOOT.INI 中加 c:\grldr="Start GRUB4DOS",然后只要一个 grldr 文件,不需要 grldr.mbr 文件。为何在 Vista 下要带上这个文件?有办法和原来一样只要一个 grldr ,不带 grldr.mbr 吗?
Last edited by NaturalJ0 on 2008-5-13 at 12:37 AM ]
These days I'm just concerned about this. Just right, copy it back and study it well. Thanks.
--------------------------------------------------------------------------------------------------
After reading, I want to ask a question. I'm relatively green, please forgive me.
In the past, when using XP, I could add c:\grldr="Start GRUB4DOS" in BOOT.INI, and then only need a grldr file, no need for the grldr.mbr file. Why in Vista do I need to bring this file? Is there a way to be the same as before, only need a grldr, not bring grldr.mbr?
Last edited by NaturalJ0 on 2008-5-13 at 12:37 AM ]
|
|
2008-5-12 23:22 |
|
|
billbear
新手上路

积分 4
发帖 2
注册 2009-2-1
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
实际上, vista 和 win7 尽管使用 bcd,但仍然会去读 boot.ini(如果有的话)。因此可以沿用老办法。在 c 盘根目录自己写一个 boot.ini :
[boot loader]
[operating systems]
c:\grldr.mbr="grub4dos"
请注意上面的引号,xp 是可以不用引号的, vista 和 win7 必须有。
然后把 grldr 和 grldr.mbr 拷贝到 c 盘根目录就可以了。
Actually, although Vista and Win7 use BCD, they will still read boot.ini (if it exists). Therefore, the old method can be continued. Write a boot.ini in the root directory of drive C yourself:
c:\grldr.mbr="grub4dos"
Please note the quotes above. For XP, quotes are not needed, but they are required for Vista and Win7.
Then copy grldr and grldr.mbr to the root directory of drive C.
|
|
2009-2-3 22:02 |
|