Windows Preinstallation Environment (also known as Windows PE and WinPE) is a lightweight version of Windows used for the deployment of PCs, workstations, and servers, or troubleshooting an operating system while it is offline. It is intended to replace MS-DOS boot disks and can be booted via USB flash drive, PXE, iPXE, CD-ROM, or hard disk. Traditionally used by large corporations and OEMs (to preinstall Windows client operating systems on PCs during manufacturing), it is now widely available free of charge via the Windows Automated Installation Kit (WAIK).
In a technician machine (a regular Windows 7 PC) download and install the Windows Automated Installation Toolkit (WAIK).
Download available from:
For 64 bits:
copype amd64 C:\winPE_amd64
For 32 bits:
copype x86 C:\winPE_x86
NOTE:
From now on we assume that will deploy 64-bit Windows PE files.
Mount the WindowsPE image to perzonalize later
Dism /Mount-Wim /WimFile:"C:\winPE_amd64\winpe.wim" /index:1 /MountDir:"C:\winPE_amd64\mount"
Modify the Startnet.cmd script to include your customized commands (see the following example code). This file is located at C:\winPE_amd64\mount\Windows\System32\Startnet.cmd.
@echo off echo Trying to load networks drivers... wpeinit ping 10.12.1.36 > NUL if errorlevel 1 goto finish if errorlevel 0 goto continue :continue echo Networks drivers loaded successfully echo Mounting network drive in Q: rem Mounting Samba share in q: net use q: \\10.12.1.36\isos echo Accessing the shared resource in Q: q: menu-os.cmd :finish echo Fail to load network driver!! echo You must to load it manually using 'drvload.exe' echo Sorry!!
You can also call other batch files or command line scripts from this file.
Note that the code above mount a share located in \\10.12.1.36\ISOs (this is your Windows/Samba server) and run 'menu-os.cmd', this file will be located in mounted shared.
For Plug and Play or networking support, make sure that you include a call to wpeinit in your customized Startnet.cmd script. For more info, see Wpeinit and Startnet.cmd: Using WinPE Startup Scripts.
Wpeinit outputs log messages to c:\Windows\system32\wpeinit.log.
del C:\winPE_amd64\ISO\boot\bootfix.bin
This step is optional!!
md "C:\winPE_amd64\mount\windows\<MyApp>"
Xcopy C:\<MyApp> "C:\winPE_amd64\mount\windows\<MyApp>"
If your app requires temporary storage, or if Windows PE becomes unresponsive when it runs an app, you may need to increase the amount of temporary storage (scratch space) allocated to Windows PE.
This step is optional!!
Windows PE reserves memory on the X: drive to unpack the Windows PE files, plus additional temporary file storage, known as scratch space, that can be used by your applications. By default, this is 512MB for PCs with more than 1GB of RAM, otherwise the default is 32MB. Valid values are 32, 64, 128, 256, or 512:
Dism /Set-ScratchSpace:128 /Image:"C:\winPE_amd64\mount"
This step is optional!!
If you've got multiple versions of Windows PE, you can set the background image so you can instantly tell which version of Windows PE is running.
Change the security permissions of the Windows PE background image file (\windows\system32\winpe.jpg). This allows you to modify or delete the file:
Finally replace the winpe.jpg file with your own image file.
This step is optional!!
Some Windows PE settings can be managed by using an answer file, such as firewall, network, and display settings. Create an answer file, name it unattend.xml, and add it to the root of the Windows PE media to process these settings. For more information, see Wpeinit and Startnet.cmd: Using WinPE Startup Scripts.
Dism /Unmount-Wim /MountDir:"C:\winPE_amd64\mount" /commit
copy C:\winPE_amd64\winpe.wim C:\winPE_amd64\ISO\Sources\Boot.wim
oscdimg -n -bC:\winPE_amd64\etfsboot.com C:\winPE_amd64\ISO C:\winPE_amd64\winpe_amd64.iso
If you want to edit a WinPE ISO image previously created just follow the next steps:
A Windows/Samba share is required to export Windows installations.
First we need to create a directory in /srv to storage Windows installations, for instance:
# mkdir -p /srv/samba-shares/ISOs
Within create a subdirectory for each installation of Windows, ie:
mkdir -p /srv/samba-shares/ISOs/{Win2008R2-ENG,Win2008x32-ENG,Win2008x64-ENG,Win2012R2-VL-ENG,Win7SP1-allver-ESP,Win8.1enterprise-withupdate-x32-ENG,Win8.1enterprise-withupdate-x32-ESP,Win8.1enterprise-withupdate-x64-ENG,Win8.1enterprise-withupdate-x64-ESP,Win8-allver-ESP}
Finally begins to copy the contents of Windows ISO in the right directory.
To configure Samba4 share with public access (no require a valid user and password), check the following lines in /etc/samba/smb.conf
security = user map to guest = Bad User
To add a new share (public share):
[ISOs] comment = Windows Installations path = /srv/samba-shares/WinISOs guest ok = Yes
# testparm
# service sernet-samba-smbd restart # service sernet-samba-nmbd restart
To list the shares resources on your Samba server:
# smbclient -L localhost -N
The option -N don't prompt for authentication!!
To access to a public resource:
# smbclient //localhost/ISOs -N -c 'ls'
At this point you have configured a public Samba share with many Windows installations inside, so to show the installations menu when boot Windows PE, create the following files in /srv/samba-shares/WinISOs/:
/srv/samba-shares/WinISOs/menu-os.cmd
@echo off REM Selecting the correct menu if %PROCESSOR_ARCHITECTURE%==x86 ( menu-os-x32.cmd ) else ( menu-os-x64.cmd )
/srv/samba-shares/WinISOs/menu-os-x32.cmd
@echo off echo Starting menu... :menu ECHO. ECHO ............................................... ECHO INSTALLATION MENU - DIC UCLV ECHO ............................................... ECHO. ECHO 1 - Install Windows Server 2008 x32 ENGLISH ECHO 2 - Install Windows 7 SP1 All Version SPANISH ECHO 3 - Install Windows 8 All Version SPANISH ECHO 4 - Install Windows 8.1 Enterprise with Update x32 ENGLISH ECHO 5 - Install Windows 8.1 Enterprise with Update x32 SPANISH ECHO q - EXIT ECHO. REM Selecting an option SET /P M=Select an option by a number or 'q' to exit, then press ENTER: IF %M%==1 GOTO win2008x32 IF %M%==2 GOTO win7sp1allversp IF %M%==3 GOTO win8allversp IF %M%==4 GOTO win8.1enterprise-withupdate-x32-eng IF %M%==5 GOTO win8.1enterprise-withupdate-x32-esp IF %M%==q GOTO EOF REM Sections :win2008x32 ECHO You choose to install Windows 2008 x32 ENGLISH PAUSE ECHO Starting setup.exe q:\Win2008x32-ENG\setup.exe CLS GOTO menu :win7sp1allversp ECHO You choose to install Windows 7 SP1 All Version SPANISH PAUSE ECHO Starting setup.exe q:\Win7SP1-allver-ESP\setup.exe CLS GOTO menu :win8allversp ECHO You choose to install Windows 8 All Version SPANISH PAUSE ECHO Starting setup.exe q:\Win8-allver-ESP\setup.exe CLS GOTO menu :win8.1enterprise-withupdate-x32-eng ECHO You choose to install Windows 8.1 Enterprise x32 with Update ENGLISH PAUSE ECHO Starting setup.exe q:\Win8.1enterprise-withupdate-x32-ENG\setup.exe CLS GOTO menu :win8.1enterprise-withupdate-x32-esp ECHO You choose to install Windows 8.1 Enterprise x32 with Update SPANISH PAUSE ECHO Starting setup.exe q:\Win8.1enterprise-withupdate-x32-ESP\setup.exe CLS GOTO menu :EOF ECHO. ECHO To reload the installation menu type 'menu-os.cmd' PAUSE CLS
/srv/samba-shares/WinISOs/menu-os-x64.cmd
@echo off echo Starting menu... :menu ECHO. ECHO ............................................... ECHO INSTALLATION MENU - DIC UCLV ECHO ............................................... ECHO. ECHO 1 - Install Windows Server 2008 x64 ENGLISH ECHO 2 - Install Windows Server 2008R2 ENGLISH ECHO 3 - Install Windows Server 2012R2 VL ENGLISH ECHO 4 - Install Windows 8.1 Enterprise with Update x64 ENGLISH ECHO 5 - Install Windows 8.1 Enterprise with Update x64 SPANISH ECHO q - EXIT ECHO. REM Selecting an option SET /P M=Select an option by a number or 'q' to exit, then press ENTER: IF %M%==1 GOTO win2008x64 IF %M%==2 GOTO win2008R2 IF %M%==3 GOTO win2012R2VL IF %M%==4 GOTO win8.1enterprise-withupdate-64-eng IF %M%==5 GOTO win8.1enterprise-withupdate-x64-esp IF %M%==q GOTO EOF REM Sections :win2008x64 ECHO You choose to install Windows 2008 x64 ENGLISH PAUSE ECHO Starting setup.exe q:\Win2008x64-ENG\setup.exe CLS GOTO menu :win2008R2 ECHO You choose to install Windows 2008R2 ENGLISH PAUSE ECHO Starting setup.exe q:\Win2008R2-ENG\setup.exe CLS GOTO menu :win2012R2VL ECHO You choose to install Windows 2012R2 VL ENGLISH PAUSE ECHO Starting setup.exe q:\Win2012R2-VL-ENG\setup.exe CLS GOTO menu :win8.1enterprise-withupdate-x64-eng ECHO You choose to install Windows 8.1 Enterprise x64 with Update ENGLISH PAUSE ECHO Starting setup.exe q:\Win8.1enterprise-withupdate-x64-ENG\setup.exe CLS GOTO menu :win8.1enterprise-withupdate-x64-esp ECHO You choose to install Windows 8.1 Enterprise x64 with Update SPANISH PAUSE ECHO Starting setup.exe q:\Win8.1enterprise-withupdate-x64-ESP\setup.exe CLS GOTO menu :EOF ECHO. ECHO To reload the installation menu type 'menu-os.cmd' PAUSE CLS
NOTE: To add or remove Windows installations modify menu-os-x32.cmd or menu-os-x64.cmd
The configuration for PXE menu may look like:
LABEL WinPE for 32 bits systems kernel memdisk append iso raw initrd=/commons/sysinstall/winpe/winpe_x86.iso LABEL WinPE for 64 bits systems kernel memdisk append iso raw initrd=/commons/sysinstall/winpe/winpe_amd64.iso
Where WinPE ISO files are copied in /srv/tftp/commons/sysinstall/winpe/ directory.