无忧启动论坛

标题: 这些代码应该怎样处理 [打印本页]

作者: chanel    时间: 2013-4-11 20:10
标题: 这些代码应该怎样处理
本帖最后由 chanel 于 2013-4-11 20:15 编辑

有一个批处理模块AutoMENU,代码如下。如果用G4D命令command /BOOT/GRUB/Automenu引导,在GFX模式下会出现乱码,在VBE模式下则没有乱码。怎样实现在GFX模式显示正常?还有,显示的菜单位置有些偏,此批处理调整菜单位置的命令是哪些?








!BAT
debug off
checkrange 20110918:-1 read 0x8278 || echo Please use grub4dos-0.4.5b-2011-09-18 or above! && exit 1
if NOT "%automok%"=="YES" &&  call :begin
configfile (md)0x23000+0x10

:begin
set spacing=8
echo -e debug off                        \n#terminal --font-spacing=    \ndefault 3\ntimeout 60\ntitle\nclear\ntitle\nclear\ntitle\nclear > (md)0x23000+0x10
find --set-root --ignore-cd --ignore-floppies /ISOS/setup.bat && ls /ISOS/ | call :automenu ! set /a spacing=%spacing%+2
call :defaultmenu
write --offset=0 (md)0x23000+0x10 terminal --font-spacing=0:%spacing%
set automok=YES
exit


:automenu
if "%1"=="" exit
if not "%1"=="" call :makemenu %1
shift
goto :automenu
exit

:makemenu
if /i "%~x1"==".iso" && call :iso %1
exit


:iso
ls (0xfa)/ && map --unmap=0xfa && map --rehook
map ()/ISOS/%1 (0xfa) || echo 文件不连续!无法用该1%安装Windows。 &&  pause --wait=6 && exit
map --rehook
if exist (0xfa)/WIN51 && if exist %ufd%srs/siso && call :winnt5x %1 ! call :WINNT6x %1
exit

:winnt5x
echo -e title                           \xE5\x90\xAF\xE5\x8A\xA8\x20\x20%~n1                                                 >> (md)0x23000+0x10
echo -e command %ufd%vbe/NT5XSETUP %1 >> (md)0x23000+0x10
exit


:WINNT6x
echo -e title                           \xE5\x90\xAF\xE5\x8A\xA8\x20\x20%~n1 (Shift+F10)                                >> (md)0x23000+0x10
echo find --set-root --ignore-cd --ignore-floppies /ISOS/%1 >> (md)0x23000+0x10
echo -e write --offset=14 ()/ISOS/Setup.bat S                                                                                                         ; >> (md)0x23000+0x10
echo -e write --offset=14 ()/ISOS/Setup.bat start template.bat %1 >> (md)0x23000+0x10
echo -e if exist (0xfa)/ && map --unmap=0xfa && map --rehook  >> (md)0x23000+0x10
echo -e map ()/ISOS/%1 (0xfa)\nmap --rehook\nchainloader (0xfa) >> (md)0x23000+0x10
exit

:defaultmenu
find  --devices=h /ntldr && call :bntldr ! set /a spacing=%spacing%+1
find  --devices=h /bootmgr && call :bbootmgr ! set /a spacing=%spacing%+1
set i=1
cdrom --init && map --rehook && call :cda %i% ! set /a spacing=%spacing%+1

echo  title                           资源管理器 >> (md)0x23000+0x10
echo -e command %ufd%VBE/filelist                                                                                        >> (md)0x23000+0x10

echo  title                           GRUB命令行 >> (md)0x23000+0x10
echo -e commandline                                                                                                        >> (md)0x23000+0x10

echo  title                           磁盘  映射 >> (md)0x23000+0x10
echo -e command %ufd%VBE/devmap                                        \x7C\x7C configfile (md)0x23000+0x10                        >> (md)0x23000+0x10

echo  title                           重      启 >> (md)0x23000+0x10
echo -e reboot >> (md)0x23000+0x10
echo  title                           关      机 >> (md)0x23000+0x10
echo -e halt >> (md)0x23000+0x10
echo  title                           返回主菜单 >> (md)0x23000+0x10
echo -e configfile %ufd%VBE/menu.lst >> (md)0x23000+0x10
exit

:cda
ls (cd%i%)/ && call :cdb %i% && exit
set /a i=%i%+1
if %i%>=4 && exit
goto :cda
exit



:cdb
echo  title                           从光驱启动 >> (md)0x23000+0x10
echo -e chainloader (cd%1)   \x7C\x7C configfile (md)0x23000+0x10        >> (md)0x23000+0x10
exit

:bntldr
echo  title                           启动Windows 2K/2K3/XP >> (md)0x23000+0x10
echo -e command %ufd%VBE/findboot ntldr                                \x7C\x7C configfile (md)0x23000+0x10                        >> (md)0x23000+0x10
exit

:bbootmgr
echo  title                           启动Windows Vista/7/8 >> (md)0x23000+0x10
echo -e command %ufd%VBE/findboot bootmgr                       \x7C\x7C configfile (md)0x23000+0x10                        >> (md)0x23000+0x10
exit
作者: 2010dewuyou    时间: 2013-4-11 23:23
本帖最后由 2010dewuyou 于 2013-4-12 00:07 编辑
在GFX模式下会出现乱码

指定字体或(并)把中文转换为utf-8编码,像:
:winnt5x
echo -e title                           \xE5\x90\xAF\xE5\x8A\xA8\x20\x20%~n1  (以下略)

title命令之后那里




顶头空行由这里造成:



行头空格由这里造成:





Automenu中没有指定gfx或vbe模式,也没有指定字体,背景之类
你2个图都不是gfx模式,贴出你的菜单看看


作者: zhaohj    时间: 2013-4-12 09:46
把简单的问题搞复杂化了,这样的菜单有必要用批处理生成吗?
作者: 2011ryoohki    时间: 2013-4-12 14:08
啧啧,一看就是用   五子登科 的PE
作者: chanel    时间: 2013-4-14 14:21
菜单头如下,哪一句可以调整菜单外框的位置,使之居中。

!BAT
debug off
checkrange 20110918:-1 read 0x8278 || echo Please use grub4dos-0.4.5b-2011-09-18 or above! && exit 1
if NOT "%automok%"=="YES" &&  call :begin
configfile (md)0x23000+0x10

:begin
set spacing=5
echo -e debug off         \n#terminal --font-spacing=    \ndefault 1\ntimeout 10\ntitle\nclear > (md)0x23000+0x10
find --set-root --ignore-cd --ignore-floppies /ISOS/setup.bat && ls /ISOS/ | call :automenu ! set /a spacing=%spacing%+2
call :defaultmenu
write --offset=0 (md)0x23000+0x10 terminal --font-spacing=0:%spacing%
set automok=YES
exit


作者: 2010dewuyou    时间: 2013-4-14 17:50
chanel 发表于 2013-4-14 14:21
菜单头如下,哪一句可以调整菜单外框的位置,使之居中。

!BAT

目测使用了menuset
而且不在你给出的这段BAT中
你还是去看看教程再改吧




欢迎光临 无忧启动论坛 (http://wuyou.net/) Powered by Discuz! X3.3