Preparing WinPE 3.0 for PXE-Boot

Veröffentlicht von

This script is based of the scripts provided by the german institution “Regionales Rechenzentrum für Niedersachsen” (R|R|Z|N).

It creates all necessary files in one folder including the boot files in one step.

You just need to upload the folder to your tftproot folder and make a copy of the bootmgr.exe from within the Boot folder to your tftproot folder.

At the end you will get a rudimentary WinPE with a simple Command Prompt.

If you want to have a more advanced WinPE take a look at this article.

Pre-Requirements

Microsoft Windows AIK for Windows 7
This script needs to be run from an administrative Deployment Tools Command Prompt.

Script

@echo off<br />
rem Erstellung von WinPE-Images und Rauskopieren der benoetigten Dateien<br />
rem vgl. Microsoft-TechNet, Walkthrough: Deploy an Image by Using PXE<br />
rem Auszufuehren innerhalb der WAIK-Eingabeaufforderung f. Bereitst.<br />
rem 20090826-HH</p>
<p>Set PXEDest=C:pxe-tftp<br />
Set OSFolder=Boot<br />
Set x86wim=winpex86.wim<br />
Set x64wim=winpex64.wim<br />
Set createx64=false</p>
<p>if exist %PXEDest% rmdir %PXEDest% /s /q<br />
mkdir %PXEDest%<br />
mkdir %PXEDest%%OSFolder%<br />
rem Create WinPE-images<br />
if exist %PXEDest%winpe-x86 rmdir %PXEDest%winpe-x86 /s /q<br />
call copype.cmd x86 %PXEDest%winpe-x86<br />
if exist %PXEDest%winpe-x64 rmdir %PXEDest%winpe-x64 /s /q<br />
call copype.cmd amd64 %PXEDest%winpe-x64<br />
rem Dateien architekturunabhaengig, amd64 hat aber zusaetzlich wdsmgfw.efi<br />
imagex /mount %PXEDest%winpe-x64winpe.wim 1 %PXEDest%winpe-x64mount<br />
xcopy %PXEDest%winpe-x64mountWindowsBootPXE* %PXEDest%%OSFolder% /s /e<br />
imagex /unmount %PXEDest%winpe-x64mount<br />
copy “%ProgramFiles%Windows AIKToolsPEToolsx86bootboot.sdi” %PXEDest%%OSFolder%<br />
copy %PXEDest%winpe-x86winpe.wim %PXEDest%%OSFolder%%x86wim%<br />
copy %PXEDest%%OSFolder%pxeboot.n12 %PXEDest%%OSFolder%pxeboot.0<br />
if “%createx64%“==“true” copy %PXEDest%winpe-x64winpe.wim %PXEDest%%OSFolder%%x64wim%</p>
<p>rem BCD-Erstellung fuer PXE-Boot von WAIK-Windows-7<br />
rem vgl. http://www.rrzn.uni-hannover.de/anl-waikpxe.html<br />
rem 20100716-HH<br />
pushd %PXEDest%%OSFolder%<br />
%systemroot%system32bcdedit -createstore BCD<br />
%systemroot%system32bcdedit -store BCD -create {ramdiskoptions}<br />
%systemroot%system32bcdedit -store BCD -set {ramdiskoptions} ramdisksdidevice boot<br />
%systemroot%system32bcdedit -store BCD -set {ramdiskoptions} ramdisksdipath %OSFolder%boot.sdi<br />
for /f ” usebackq delims={} tokens=2″ %%i IN (`%systemroot%system32bcdedit -store BCD -create /d “WinPE-x86 Boot Image” /application osloader`) do set GUIDx86=%%i<br />
if “%createx64%“==“true” for /f ” usebackq delims={} tokens=2″ %%i IN (`%systemroot%system32bcdedit -store BCD -create /d “WinPE-x64 Boot Image” /application osloader`) do set GUIDx64=%%i<br />
echo GUID x86: %GUIDx86%<br />
if “%createx64%“==“true” echo GUID x64: %GUIDx64%<br />
%systemroot%system32bcdedit -store BCD -enum<br />
echo.<br />
%systemroot%system32bcdedit -store BCD -set {%GUIDx86%} systemroot Windows<br />
%systemroot%system32bcdedit -store BCD -set {%GUIDx86%} detecthal Yes<br />
%systemroot%system32bcdedit -store BCD -set {%GUIDx86%} winpe Yes<br />
%systemroot%system32bcdedit -store BCD -set {%GUIDx86%} osdevice ramdisk=[boot]%OSFolder%%x86wim%<br />
%systemroot%system32bcdedit -store BCD -set {%GUIDx86%} device ramdisk=[boot]%OSFolder%%x86wim%,{ramdiskoptions}<br />
if “%createx64%“==“true” %systemroot%system32bcdedit -store BCD -set {%GUIDx64%} systemroot Windows<br />
if “%createx64%“==“true” %systemroot%system32bcdedit -store BCD -set {%GUIDx64%} detecthal Yes<br />
if “%createx64%“==“true” %systemroot%system32bcdedit -store BCD -set {%GUIDx64%} winpe Yes<br />
if “%createx64%“==“true” %systemroot%system32bcdedit -store BCD -set {%GUIDx64%} osdevice ramdisk=[boot]%OSFolder%%x64wim%<br />
if “%createx64%“==“true” %systemroot%system32bcdedit -store BCD -set {%GUIDx64%} device ramdisk=[boot]%OSFolder%%x64wim%,{ramdiskoptions}<br />
%systemroot%system32bcdedit -store BCD -create {bootmgr} /d “WinPE BootManager”<br />
%systemroot%system32bcdedit -store BCD -timeout 30<br />
%systemroot%system32bcdedit -store BCD -default {%GUIDx86%}<br />
if not “%createx64%“==“true” %systemroot%system32bcdedit -store BCD -displayorder {%GUIDx86%}<br />
if “%createx64%“==“true” %systemroot%system32bcdedit -store BCD -displayorder {%GUIDx86%} {%GUIDx64%}<br />
popd<br />
goto end</p>
<p>:end<br />
echo.<br />
echo.<br />
echo.<br />
echo Transfer the &quot;%OSFolder%&quot; folder from %PXEDest% to the tftp-root folder of your PXE-Server.<br />
pause

Explanations

PXEDest defines the folder where the script will work in

OSFolder defines your folder which needs to be uploaded to your PXE-Server

x86wim and x64wim defines the naming of the wim files you’ll get

createx64 if set to true will additionally create a rudimentary 64Bit PXE environment

Kommentar hinterlassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.