@echo off
setlocal EnableDelayedExpansion
set dv=f
set bootdisk=c:
set "x=f:\boot\imgs\WePE_64_V1.2.iso"
rem 若是變量x裏面含有/左斜槓,則不能被做爲關鍵詞,必須加上\轉義字符linux
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!windows
rem 查找包含title*WePE_64_V1.2.iso所在行,刪除下面的6行:
sed -i -e "/title\(.*\)!x2!/,+6d" "%bootdisk%\menu.lst"spa
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 (rem
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"
)it
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"
)io
)
)
)變量
rem windows的回車換行符是\r\n,linux的是\n,因此要替換:
sed -i -e "s/$/\r/g" "%bootdisk%\menu.lst"
rem start "1" "%bootdisk%\menu.lst"
rem pausesed