陈晓猫

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

@echo off
setlocal EnableDelayedExpansion
set dv=f
set bootdisk=c:
set "x=f:\boot\imgs\WePE_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\title 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/@@/\r\n/g" "%bootdisk%\menu.lst"
)

if /i "!x:~-3!"=="iso" (
sed -e "!y!i\title 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/@@/\r\n/g" "%bootdisk%\menu.lst"
)

)
)
)

rem windows的回车换行符是\r\n,linux的是\n,所以要替换:
sed -i -e "s/$/\r/g" "%bootdisk%\menu.lst"
rem start "1" "%bootdisk%\menu.lst"
rem pause

posted on 2019-05-10 12:08  陈晓猫  阅读(259)  评论(0编辑  收藏  举报