How to create a custom Windows 8 Pre-boot Environment
The windows PE 8 pre-boot environment 4.0+ (win8) & 4.+ is very useful for a variety of things from antivirus scanning, system restores, ghosting, dism, browsing, sysprep, troubleshooting, and etc. The following will show you how I've used the environment to make my life and others better and easier. This is why it was designed and implemented by Microsoft, to make our lives easier in the long run. This is also a requirement for imaging with SCCM 2012+ and lite touch.
Needed to create a custom 4.0+ WinPE Environment:
Windows Automated Install Kit 4.0 (win 8): http://www.microsoft.com/en-us/download/details.aspx?id=30652
Install Windows Automated Install Kit then the Supplement to prep your Windows Automated Install Kit to the latest version.
This will fulfill the requirements needed to perform and create the following:
For the 64 bit version replace x86 with amd64 in the following code
NOTE: that most apps & portable apps will only run in 32 bit WINPE builds. This is unless of course you install the 64 bit apps.
NOTE: UEFI desktops will most likey require a 64 bit WINPE
****** NEWER WINPE BE INSTRUCTIONS LINKS ********
How to create a custom WinPE 8 / WinPE 8.1 (5.0 / 5.1) boot cd iso or usb boot key
Instructions
#Open a WINPE Deployment Tools Cmd Prompt as Administrator
#Create the basic file structure for your work area
copype.cmd x86 c:\winpe
#Insert a Windows 8.1 Disc in your Cdrom Drive. Referenced as G:\ below replace with your drive letter
#Mount the Windows Image, Extract the WinRe.wim for use as the base for your WinPE disc
#Then cleanup the mount and directory as you won't need them again
# ***** NOTE the WINRE.WIM is now a hidden system file *****
md c:\winpe\disc
dism /mount-image /imagefile:g:\sources\install.wim /index:1 /readonly /mountdir:c:\winpe\disc
xcopy /h c:\winpe\disc\windows\system32\recovery\winre.wim c:\winpe\winpe.wim
dism /unmount-image /mountdir:c:\winpe\disc
rd c:\winpe\disc
#Open the image and mount it for editing
#the image is like a separate hard drive
#whose root starts at c:\winpe\mount
#ALL changes made under this directory will
#be saved to the WinPE image when you
#commit and unmount, also unhide it.
attrib -s -h c:\winpe\winpe.wim
md c:\winpe\mount
dism /mount-image /imagefile:c:\winpe\winpe.wim /index:1 /mountdir:c:\winpe\mount
#Adding Drivers to the image (optional)
#
#The easiest way to add drivers is to extract each driver to its own directory
#under one root directory example:
#
# c:\winpe\drivers
# -> Nic driver for dell
# -> Nic driver for hp
# -> Driver pack from Dell
# -> Driver pack for HP 64xx Laptops etc..
#
# Then add them all at once with the following command
dism /image:c:\winpe\mount /add-driver /driver:c:\winpe\drivers /recurse
# Further Customization (optional)
#
#Under the now open image's root: c:\winpe\mount
#
# Edit Winpeshl.ini : c:\winpe\mount\windows\system32\winpeshl.ini
# Editing this file will allow you to autoload whatever you like on boot
#
# Editing Examples:
#Example Launch cmd.exe automatically
#winpeshl.ini:
[LaunchApps]
%SYSTEMDRIVE%\Windows\system32\cmd.exe
#Example Launch startnet.cmd automatically ( Starts networking allows launching more apps )
# Normally I'd say this is the best route since its a batch file
# you can edit to do a million things from starting a number of
# apps you save into the build: GHOST / PORTABLE APPS / ImageX / Virus Scanners / File Explorers
#winpeshl.ini:
[LaunchApps]
%SYSTEMDRIVE%\Windows\system32\startnet.cmd
#Example Launch recenv.exe automatically ( Starts recovery )
#winpeshl.ini:
[LaunchApps]
%SYSTEMDRIVE%\sources\recovery\recenv.exe
# STARTNET.CMD Further Customization (optional)
#
# Under the now open image's root: C:\winpe\mount
#
# Edit STARTNET.CMD : c:\winpe\mount\windows\system32\STARTNET.CMD
#
# Editing Example:
# WPEINIT Required for networking
wpeinit
# Set your PATH to include the things you want easy access to
#
set Path=%Path%;%SYSTEMDRIVE%\ghost;%SYSTEMDRIVE%;%SYSTEMDRIVE%\apps;%SYSTEMDRIVE%\apps\firefox;%SYSTEMDRIVE%\apps\cexplorer
# Good to run IPCONFIG just to have your IP info on the screen
#
ipconfig
#
# Example things you can automatically start
#
call %SYSTEMDRIVE%\sources\recovery\recenv.exe
call %SYSTEMDRIVE%\ghost\ghost32.exe
call %SYSTEMDRIVE%\windows\system32\cmd.exe
call %SYSTEMDRIVE%\PORTABLEAPPSDIR\PORTAPPS.EXE
# CLOSING/SAVING/COMMITTING THE IMAGE
# Unmount the Image with commit, This saves changes
dism /unmount-image /mountdir:c:\winpe\mount /commit
# CREATE AN ISO / CDIMAGE
# Copy the now complete custom WINPE.WIM, then create the ISO
#
copy c:\winpe\winpe.wim c:\winpe\media\sources\boot.wim /Y
makewinpemedia /iso c:\winpe c:\winPE\bootcd.iso
#Make a USB Boot:
# This used to be a much bigger pain in the ass, but hooray for progress
# Replace H: below with the drive of your USB stick
MakeWinPEMedia /UFD c:\winpe H: