Friday, 25 September 2009

Creating a Windows PE 3 Bootable USB device

WinPE 3I’ve used Windows PE for a long time. And I’ve grown to love it. It’s an extremely useful tool, not just for OS installation, but for diagnostics.

Since there’s a version of WinPe for x64 & x86 (& itanium) I like to keep both x64 & x86 on my USB stick. Essentially copying the each version to the root of the USB stick as needed. Meaning at any one time I have three copies of WinPE on my USB stick. Other applications I copy directly to my USB stick, so that I don’t have to remount the image every time i need another application added.

Shortly after Windows 7 was released came a new version of WinPE, WinPE 3.0 on the Windows Automated Installation Kit.

Preparing the USB stick.

WinPE Diskpart Preperation You’ll need to prepare the USB stick. To do this open a command prompt using Run As Administrator and use the following commands.

diskpart
list disk
select disk 7
clean
create partition primary
select partition 1
active
format quick fs=fat32
assign
exit

Make sure you select the correct disk by adjusting the third command above.

Getting WinPE 3.0 Quickly

I’ve already done this so I’ve uploaded it to save you some time. The new Windows AIK is 1.75Gb my files are 170Mb & 146Mb for x64 & x86 respectively. I’ve detailed the packages I’ve used below.

hotfile Files are hosted with HotFile as I don’t have enough storage to host them myself.

  • Both x86 & x64 versions are available.
  • WMI, HTA & Scripting Packages
  • ImageX copied to the image (System32 folder).

Once you’ve downloaded the file above, you can either copy the contents of the version of WinPE you wish to use to the root of the USB stick.

Creating a WinPE 3 Image

To create your own customised WinPE 3 image, you can follow Microsoft’s instructions here. The page details all the packages you can install and how to install them. The commands I used for each version are below.

Remember to run the Deployment tools Command Prompt As Administrator.

32-Bit WinPE 3

copype.cmd x86 c:\winpe_x86
copy c:\winpe_x86\winpe.wim c:\winpe_x86\ISO\sources\boot.wim
Dism /Mount-Wim /WimFile:C:\winpe_x86\ISO\sources\boot.wim /index:1 /MountDir:C:\winpe_x86\mount
Dism /image:C:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-wmi.cab"
Dism /image:C:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-hta.cab"
Dism /image:C:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-scripting.cab"
copy "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" C:\winpe_x86\mount\Windows\System32\imagex.exe
Dism /unmount-Wim /MountDir:C:\winpe_x86\mount /Commit

64-Bit WinPE 3

copype.cmd amd64 c:\winpe_amd64
copy c:\winpe_amd64\winpe.wim c:\winpe_amd64\ISO\sources\boot.wim
Dism /Mount-Wim /WimFile:C:\winpe_amd64\ISO\sources\boot.wim /index:1 /MountDir:C:\winpe_amd64\mount
Dism /image:C:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\amd64\WinPE_FPs\winpe-wmi.cab"
Dism /image:C:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\amd64\WinPE_FPs\winpe-hta.cab"
Dism /image:C:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\amd64\WinPE_FPs\winpe-scripting.cab"
copy "C:\Program Files\Windows AIK\Tools\amd64\imagex.exe" C:\winpe_amd64\mount\Windows\System32\imagex.exe
Dism /unmount-Wim /MountDir:C:\winpe_amd64\mount /Commit

Once you’ve followed all the instructions you can copy the contents of c:\<architecture>\ISO\ to the root of the usb stick you are using.

8 comments:

Ryan said...

While your script uses DISM to install the language neutral packages, it fails to install the language specific packages. For example, on a 32-bit platform (for users in the US), you could find language specific packages in "C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us".

David Owen said...

While those components remain optional, I agree that some users will want to use them, but I suspect those users will read the Technet Article, not my blog.

Daniel said...

Hi David,

It's pretty straightforward. Thanks for that.

But how to start it up with the GUI instead of a command prompt? (like the old winPE 2 iso you can find around).

I mean, can it start with the start button available, at least to access the windows explorer?

PS: sorry, but i don't acknowledge the technical jargons!

Cheers,

Dan

darren s said...

This looks great but the links are dead.

Could you reup them please?

factorclassic said...

kingston usb stick $ Gb is not listed under diskpart.

Also an error seen below is contradition to itself - dism is present and working and yet it reports "mount-wim" option as "unknown" ????

------------------------------------
Deployment Image Servicing and Management tool
Version: 6.1.7600.16385


Error: 87

The mount-wim option is unknown.
For more information, refer to the help by running DISM.exe /?.

The DISM log file can be found at C:\WINDOWS\Logs\DISM\dism.log

C:\winpe_x86>dism.exe /?

Deployment Image Servicing and Management tool
Version: 6.1.7600.16385


DISM.exe [dism_options] {WIM_command} []
DISM.exe {/Image: | /Online} [dism_options]
{servicing_command} []

DESCRIPTION:

DISM enumerates, installs, uninstalls, configures, and updates features
and packages in Windows images. The commands that are available depend
on the image being serviced and whether the image is offline or running.


IMAGE SPECIFICATIONS:

/Online - Targets the running operating system.
/Image - Specifies the path to the root directory of an
offline Windows image.

DISM OPTIONS:

/English - Displays command line output in English.
/Format - Specifies the report output format.
/WinDir - Specifies the path to the Windows directory.
/SysDriveDir - Specifies the path to the system-loader file named
BootMgr.
/LogPath - Specifies the logfile path.
/LogLevel - Specifies the output level shown in the log (1-4).
/NoRestart - Suppresses automatic reboots and reboot prompts.
/Quiet - Suppresses all output except for error messages.
/ScratchDir - Specifies the path to a scratch directory.

For more information about these DISM options and their arguments, specify an
option immediately before /?.

Examples:
DISM.exe /Mount-Wim /?
DISM.exe /ScratchDir /?
DISM.exe /Image:C:\test\offline /?
DISM.exe /Online /?

myob said...

The above error means somewhere along the line the syntax in your command line is incorrect.

I know from a lot of experience and trial and error!

it's a very frustrating error message to get, and is useless in terms of helping you find out what is wrong.

Allen said...

How to boot WinPE into a desktop screen?

Aida Baker said...

Thank you. You've certainly made the task easier for anyone who wants to set up their USB. I think that it was kind of you to share your files with your readers as well.