@echo off
for /r X:\drivers %%i in (*.inf) do drvload %%i
wpeinit
for /f "usebackq tokens=2 delims==" %%m in (`wmic nic where "NetConnectionStatus=2" get MACAddress /value ^| find "MACAddress="`) do set "MAC=%%m"
set "MAC=%MAC:~0,17%"
X:\Windows\System32\curl.exe -s -o X:\autounattend.xml "http://192.168.239.242/winpe.xml?mac=%MAC%"
X:\Windows\System32\curl.exe -s -o X:\SetupComplete.cmd "http://192.168.239.242/winpe.cmd?mac=%MAC%"
X:\Windows\System32\curl.exe -s -o X:\dp.txt "http://192.168.239.242/winpe.dp?mac=%MAC%"
diskpart /s X:\dp.txt
X:\Windows\System32\curl.exe -o W:\install.wim "http://192.168.239.242/wim/win2012r2-cn.wim"
dism /apply-image /imagefile:W:\install.wim /index:4 /applydir:W:\
del /f /q W:\install.wim
md W:\Windows\Panther
copy /y X:\autounattend.xml W:\Windows\Panther\unattend.xml
md W:\Windows\Setup\Scripts
copy /y X:\SetupComplete.cmd W:\Windows\Setup\Scripts\SetupComplete.cmd
bcdboot W:\Windows /s R: /f BIOS
wpeutil reboot
