|
感谢 zhaohj 的帮助。zhaohj 的动态菜单真的很棒。
现在 BOOTSECT 菜单版已完工,请大家帮忙测试。
BOOTSECT 是一个经过封装的单文件。在批处理执行开始,会把所有的文件载入到内存,并虚拟软驱 (fd9)
主要文件介绍:
main.lst 主菜单
choose.lst 引导代码选择菜单
MENU.BAT 硬盘选择 动态菜单 生成批处理
maincall 调用批处理
bootsec 程序执行主体,核心操作批处理 由原来的命令行版修改而来。 简单修改。
main.lst 内容:
#主菜单框架
debug off
color white/blue blue/yellow light-red/blue 10
default 5
timeout 50
#0
title GRUB4DOS BOOTSECT
clear
#1
title
clear
#2
title Update MBR [Master Boot Record]
set czlx=mbr
configfile (fd9)/CHOOSE.LST
#3
title Update DBR [Partition Boot Record]
set czlx=dbr
configfile (fd9)/CHOOSE.LST
#4
title Clear Hard Disk 1-62 sectors
set czlx=clear
(fd9)/MENU.BAT
boot
#5
title Return BOOTSECT Main Menu
configfile (fd9)/MAIN.LST
#6
title Return GRUB4DOS Boot Menu
set *
map --unmap=9
map --rehook
configfile (md)4+8
#7
title GRUB4DOS Commandline
commandline
#8
title Reboot
reboot
#9
title Halt
halt
choose.lst 内容:
debug off
color white/blue blue/yellow light-red/blue 10
default 5
timeout 50
#0
title Choose Boot Code Type
clear
#1
title
clear
#2
title nt5x
set yddm=/nt52
(fd9)/MENU.BAT
boot
#3
title nt60
set yddm=/nt60
(fd9)/MENU.BAT
boot
#4
title dos
set yddm=/dos
(fd9)/MENU.BAT
boot
#5
title Return BOOTSECT Main Menu
configfile (fd9)/MAIN.LST
maincall 内容:
!BAT by sgw888
#主调用菜单
goto %czlx%
:clear
(fd9)/BOOTSEC clear %hddisk%
goto :end
:mbr
(fd9)/BOOTSEC %yddm% /mbr %hddisk%
goto :end
:dbr
(fd9)/BOOTSEC %yddm% %acpart%
:end
set nn=
set ac=
set gt=
set hdn=
set hdp=
set hddisk=
set acpart=
set czlx=
set yddm=
configfile (fd9)/main.lst
MENU.BAT 内容:
这个文件才是关键!!! 在 zhaohj 的基础上做了少许改动。
!BAT
# changelog 2011.05.25
# 考虑到U盘usb-hdd模式启动,(hd0)会被U盘占用,这在处理时要特别小心。
debug off
set ac=
set hdp=
set /a hdn=*0x475&0xff
calc %hdn% || clear && pause --wait=10 NO Harddisk && configfile (fd9)/main.lst
set /a nn=0
set /a gt=%hdn%+2
map --rd-base=0x40000 && map --rd-size=0x1000
echo debug off > (rd)+1
echo color white/blue blue/yellow light-red/blue 10 >> (rd)+1
echo default 2 >> (rd)+1
#0
echo title ==== please select Harddisk %@date% ==== >> (rd)+1
echo clear >> (rd)+1
#1
echo title >> (rd)+1
echo clear >> (rd)+1
#2
:hdd
echo title select hd%nn% >> (rd)+1
echo clear >> (rd)+1
echo echo hd%nn% harddisk Partition information: >> (rd)+1
echo echo >> (rd)+1
echo -e checkrange 0x80 read 0x82a0 \&\& echo If be USB-HDD Boot,your first harddisk may be U-Pan \&\& >> (rd)+1
echo geometry (hd%nn%) >> (rd)+1
echo echo >> (rd)+1
echo -e geometry (hd%nn%) \x3e (md)0x300+1 >> (rd)+1
echo -e set hddisk=(hd%nn%) >> (rd)+1
echo -e cat --locate=active (md)0x300+1 \| set ac= >> (rd)+1
echo -e if not exist ac \&\& if /i \x25czlx\x25==dbr \&\& pause --wait=10 NO Active Partition,DBR can not be updated! \&\& goto %gt% >> (rd)+1
echo -e if not exist ac \&\& echo NO Active Partition! >> (rd)+1
echo -e if not exist ac \&\& set /p sfzx=Do you want to continue?(y/n) >> (rd)+1
echo -e if not exist ac \&\& if /i #\x25sfzx\x25==#y \&\& (fd9)/MAINCALL >> (rd)+1
echo -e if not exist ac \&\& if /i not #\x25sfzx\x25==#y \&\& goto %gt% >> (rd)+1
echo -e set ac=0x\x25ac\x25 >> (rd)+1
echo -e set /a ac=\x25ac\x25-3 >> (rd)+1
echo -e cat --skip=\x25ac\x25 --length=1 (md)0x300+1 \| set hdp= >> (rd)+1
echo -e echo List Active Partition (hd%nn%,\x25hdp\x25) files: >> (rd)+1
echo echo >> (rd)+1
echo -e ls (hd%nn%,\x25hdp\x25)/ \|\| echo (hd\x25nn\x25,\x25hdp\x25) partition read error, unable to list files. >> (rd)+1
echo echo >> (rd)+1
echo -e set hddisk=(hd%nn%) >> (rd)+1
echo -e set acpart=(hd%nn%,\x25hdp\x25) >> (rd)+1
echo set /p ac=Whether correct for selected harddisk or Partition (y/n)? >> (rd)+1
echo -e if /i not \x25ac\x25==y goto %gt% >> (rd)+1
echo (fd9)/MAINCALL >> (rd)+1
echo kernel >> (rd)+1
set /a nn=%nn%+1
if not %nn%==%hdn% && goto :hdd
#变量gt 指向本菜单
#返回bootsect 主菜单
echo title Return BOOTSECT Main Menu >> (rd)+1
echo clear >> (rd)+1
echo configfile (fd9)/main.lst >> (rd)+1
configfile (rd)+1
exit
以上是菜单版主要文件的源码。 |
|