批处理代码
下面是一个批处理的代码,功能是创建一个新的bcd文件,只有一个启动项,就是启动分区根目录grldr。
适合想用微软的默认pbr,可以启动bootmgr。然后用bootmgr来启动grub4dos的grldr,这样微软的默认pbr就可以使用grub4dos了。不需要修改pbr。
rem 新bcd文件的路径,以d:\bcd为例子
set bcd_path=d:\bcd
if exist %bcd_path% echo "%bcd_path% exist,please use other filename" && exit
rem 创建新bcd文件
bcdedit /createstore %bcd_path%
rem 创建主菜单入口ID
bcdedit /store %bcd_path% /create {bootmgr} /d "Windows Boot Manager"
rem 下面是创建bootsector项目的原始命令
rem bcdedit /store %bcd_path% /create /d "GRUB4DOS" /application bootsector
rem 创建bootsector项目
rem 下面是将原始命令结果的guid赋值给guid变量,方便一次性执行所有命令
FOR /F "tokens=2 delims={} " %%i in ('bcdedit /store %bcd_path% /create /d "grub4dos" /application bootsector') do set guid=%%i
bcdedit /store %bcd_path% /set {%guid%} device boot
bcdedit /store %bcd_path% /set {%guid%} path \grldr
bcdedit /store %bcd_path% /displayorder {%guid%} /addlast
REM 默认项
bcdedit /store %bcd_path% /default {%guid%}