@echo off
rem The fileserver IP
set FILESERVER=192.168.1.155
rem Share on the fileserver.
set SHARE=INSTALLERS\ISOFILES\0-WINPE
rem Username for the share
set SHAREUSER=root
rem Password for the share
set SHAREPASS=root
rem amd64 or x86
set ARCH=amd64
rem Path to hold working files. Needs about 500MB of free space.
set PEPATH="c:\winpe_%ARCH%"
rem ##########################################################
rem Don't edit anything below here
rem ##########################################################
echo Creating the PE image
call copype.cmd %ARCH% %PEPATH% > NUL
echo Mounting the image
dism /Mount-Wim /WimFile:%PEPATH%\media\sources\boot.wim /index:1 /MountDir:%PEPATH%\mount /quiet
echo Adding commands to the startup script in PE
echo. >> %PEPATH%\mount\windows\system32\startnet.cmd
echo ping %FILESERVER% >> %PEPATH%\mount\windows\system32\startnet.cmd
echo net use z: \\%FILESERVER%\%SHARE% %SHAREPASS% /u:%FILESERVER%\%SHAREUSER% >> %PEPATH%\mount\windows\system32\startnet.cmd
echo z: >> %PEPATH%\mount\windows\system32\startnet.cmd
echo z:\64.bat >> %PEPATH%\mount\windows\system32\startnet.cmd
echo Creating the pxeboot directory
mkdir %PEPATH%\pxeboot > NUL
mkdir %PEPATH%\pxeboot\Fonts > NUL
copy /y %PEPATH%\mount\windows\boot\Fonts\*.* %PEPATH%\pxeboot\Fonts\ > NUL
copy /y "%WinPERoot%\%ARCH%\Media\Boot\boot.sdi" %PEPATH%\pxeboot\ > NUL
copy /y "%WinPERoot%\%ARCH%\Media\Boot\BCD" %PEPATH%\pxeboot\ > NUL
echo Unmounting the image
dism /unmount-Wim /MountDir:%PEPATH%\mount /Commit /quiet
echo Optimizing the image
imagex /EXPORT %PEPATH%\media\sources\boot.wim 1 %PEPATH%\pxeboot\boot.wim > NUL
echo.
echo All the files you need for your PXE server are in: %PEPATH%\pxeboot\
I use that batch file to easily create WinPE media for different Windows versions. It does require the imaging tools of the Windows Kits though, but I’m guessing most people will have that installed already.
You can add and remove certain commands as needed of course, for eg adding drivers using dism and such.