|
本帖最后由 lps4290 于 2021-3-7 22:15 编辑
我109楼的语句并不是用FOR直接一步生成excel.txt,所以总耗时并没有明显增加,不用sed.exe问题也不大。
多了一个FOR仅用来读取一次win10x86_64.txt(实际只有两行),取两次值这个FOR就完成任务了,其余
流程差别不大,实测和你最新批处理总耗时几乎没变。
因为准备自用,就把你和葱哥的批处理按自己喜好整理修改了一下,有两个版本,一个总耗时几乎不变,
另一个是用FOR直接一步生成excel.txt,总耗时多3到4秒,可以考虑用sed.exe跑。两位老大有空时也可
以对比测试一下。
Win10x86_64.txt
(7.05 KB, 下载次数: 14)
版本一:总耗时几乎不变
@echo off & pushd "%~dp0"
if exist winre.wim (
echo 发现winre.wim!准备制作!
set wimfile=winre.wim & goto :start
)
if exist boot.wim goto :boot_wim
for %%i in (*.iso) do (
echo 没有发现winre.wim和boot.wim,正在尝试从iso中解压出boot.wim ......
bin\7z.exe e -o"%~dp0" -aoa "%%i" sources/boot.wim
if exist boot.wim goto :boot_wim
)
echo. & echo 找不到winre.wim、boot.wim、系统iso任何一个,按任意键退出 ......
pause>nul & EXIT
:boot_wim
echo 发现boot.wim,直接制作,准备删除卷1 ......
bin\wimlib delete boot.wim 1 --check
set wimfile=boot.wim
:start
echo. & echo 开始时间:%time% & set startT=%time%
for /f "delims=" %%i in (bin\Win10x86_64.txt) do (
echo %%i | find ".exe" >NUL && (
bin\wimlib dir %wimfile% 1 | find "." | findstr /vil "%%i">>List.txt
) || (
bin\wimlib dir %wimfile% 1 --path=windows\winsxs | find "." | findstr /vi "%%i">>List.txt
)
)
echo. & echo 正在增删削减%wimfile%包里的文件制作PE过程中,请您稍微等待 ...... & echo.
if exist excel.txt del excel.txt /f /q
for /f "delims=" %%i in (List.txt) do echo delete --force --recursive "%%i">>excel.txt
bin\wimlib dir %wimfile% 1 --path=Windows\SysWOW64 | find ".exe" >NUL && (set FD=x64) || (set FD=x86)
bin\wimlib update %wimfile%<excel.txt>NUL
bin\wimlib update %wimfile%<%FD%\add2wim.txt>NUL
bin\wimlib optimize %wimfile%
set endT=%time%
set /a costM=3%endT:~3,2%-3%startT:~3,2%
if %costM% lss 0 set /a costM=%costM%+60
set /a costT=3%endT:~9,2%-3%startT:~9,2%+(3%endT:~6,2%-3%startT:~6,2%+%costM%*60)*100
echo. & echo 结束时间:%endT% 耗时:%costT:~0,-2%.%costT:~-2% 秒
del /f /q *.txt
set output=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%wimfile%
set output=%output: =0%
ren %wimfile% "%output%"
echo. & echo 感谢您的等待,现在PE已经制作完成,%output%就是你的网络骨头版pe成品! & echo.
pause
EXIT
版本二:直接一步生成excel.txt,优点是生成的临时列表文件最少,缺点是总耗时多3~4秒,CPU占用高些。
@echo off & pushd "%~dp0"
if exist winre.wim (
echo 发现winre.wim!准备制作!
set wimfile=winre.wim & goto :start
)
if exist boot.wim goto :boot_wim
for %%i in (*.iso) do (
echo 没有发现winre.wim和boot.wim,正在尝试从iso中解压出boot.wim ......
bin\7z.exe e -o"%~dp0" -aoa "%%i" sources/boot.wim
if exist boot.wim goto :boot_wim
)
echo. & echo 找不到winre.wim、boot.wim、系统iso任何一个,按任意键退出 ......
pause>nul & EXIT
:boot_wim
echo 发现boot.wim,直接制作,准备删除卷1 ......
bin\wimlib delete boot.wim 1 --check
set wimfile=boot.wim
:start
echo. & echo 开始时间:%time% & set startT=%time%
if exist excel.txt del excel.txt /f /q
for /f "delims=" %%i in (bin\Win10x86_64.txt) do (
echo %%i | find ".exe" >NUL && (
for /f "delims=" %%a in ('bin\wimlib dir %wimfile% 1 ^| find "." ^| findstr /vil "%%i"') do echo delete --force --recursive "%%a">>excel.txt
) || (
for /f "delims=" %%a in ('bin\wimlib dir %wimfile% 1 --path=windows\winsxs ^| find "." ^| findstr /vi "%%i"') do echo delete --force --recursive "%%a">>excel.txt
)
)
echo. & echo 正在增删削减%wimfile%包里的文件制作PE过程中,请您稍微等待 ...... & echo.
bin\wimlib dir %wimfile% 1 --path=Windows\SysWOW64 | find ".exe" >NUL && (set FD=x64) || (set FD=x86)
bin\wimlib update %wimfile%<excel.txt>NUL
bin\wimlib update %wimfile%<%FD%\add2wim.txt>NUL
bin\wimlib optimize %wimfile%
set endT=%time%
set /a costM=3%endT:~3,2%-3%startT:~3,2%
if %costM% lss 0 set /a costM=%costM%+60
set /a costT=3%endT:~9,2%-3%startT:~9,2%+(3%endT:~6,2%-3%startT:~6,2%+%costM%*60)*100
echo. & echo 结束时间:%endT% 耗时:%costT:~0,-2%.%costT:~-2% 秒
del /f /q *.txt
set output=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%wimfile%
set output=%output: =0%
ren %wimfile% "%output%"
echo. & echo 感谢您的等待,现在PE已经制作完成,%output%就是你的网络骨头版pe成品! & echo.
pause
EXIT
|
|