@echo off
setlocal EnableDelayedExpansion
set dv=f
set bootdisk=c:
set "x=f:ootimgsWePE_64_V1.2.iso"
rem 如果变量x里面含有/左斜杠,则不能被作为关键词,必须加上转义字符
rem set "x2=WePE_64_V1.2.iso"
for /f %%i in ('echo !x!^|sed -e "s/(.*)\//"') do set x2=%%i
rem echo !x2!
rem !iso2[%%j]!保存的是iso wim img文件名字,把改成/,并去掉盘符:
for /f %%i in ('echo !x!^|sed -e "s/(..)//" -e "s/\/\//g"') do set x=%%i
rem echo !x!
rem 查找包含title*WePE_64_V1.2.iso所在行,删除下面的6行:
sed -i -e "/title(.*)!x2!/,+6d" "%bootdisk%menu.lst"
rem 查找第二个title的行的行号,增加启动菜单:
set y=0
for /f %%i in ('sed -n "/title/=" "%bootdisk%menu.lst" ^|sed -n "2p"') do set /a y=%%i
if !y! gtr 0 (
if /i "!x:~-3!"=="img" if /i "!x:~-12!" neq "firadisk.img" if /i "!x:~-11!" neq "winvblk.img" (
sed -e "!y!i itle floppydisk.img (!x2!)@@find --ignore-floppies --ignore-cd --set-root !x!@@map --mem --top !x! (fd0)@@map --hook@@root (fd0)@@chainloader (fd0)+1@@" -i "%bootdisk%menu.lst"
sed -i "s/@@/
/g" "%bootdisk%menu.lst"
)
if /i "!x:~-3!"=="iso" (
sed -e "!y!i itle WINPE (!x2!)@@find --ignore-floppies --ignore-cd --set-root !x!@@map --mem --top !x! (0xff)@@map --e820cycles=-1@@map --hook@@chainloader (0xff)@@" -i "%bootdisk%menu.lst"
sed -i "s/@@/
/g" "%bootdisk%menu.lst"
)
)
)
)
rem windows的回车换行符是
,linux的是
,所以要替换:
sed -i -e "s/$/
/g" "%bootdisk%menu.lst"
rem start "1" "%bootdisk%menu.lst"
rem pause