|
|
个人自用的如下:
@echo off
setlocal enabledelayedexpansion
:: 检查是否传入了参数
if "%~1"=="" (
echo 请传入一个文件名作为参数。
exit /b 1
)
::显示映像目录
dism /Get-WimInfo /WimFile:%1
::让用户输入索引号
if "%index%"=="" set /p index="请输入要安装的镜像索引号:" || set "index=1"
::检查c盘是否正确
if exist "C:\Windows" (
format c: /q /y /V:系统
) else (
format c: /q /V:系统
)
:: 释放映像到c盘
dism /Apply-Image /ImageFile:%1 /Index:%index% /ApplyDir:c:
:: wimlib-imagex apply %1 %index% c:
:: 判断文件名是否包含 "install",那通常是微软弄的安装镜像
echo %1 | findstr /i "install" >nul
if %errorlevel% == 0 (
::新建应答文件夹
md C:\Windows\Panther
::复制自动化安装和配置应答文件
copy %~dp0\unattend.xml C:\Windows\Panther\unattend.xml
)
:: 判断影像号码如果大于1,那通常是微软弄的安装镜像
if not %index% == 1 (
::新建应答文件夹
md C:\Windows\Panther
::复制自动化安装和配置应答文件
copy %~dp0\unattend.xml C:\Windows\Panther\unattend.xml
)
:: 加载esp分区
mountvol s: /s
:: 格式化esp分区
format s: /q /y
:: 安装uefi引导
bcdboot c:\windows /l zh-cn /s s: /f uefi
bootsect /nt60 s:
::重启
wpeutil reboot
endlocal
|
|