Video Screencast Help

Adventures with WinPE 3.1

Created: 21 Feb 2012 • Updated: 21 Feb 2012 | 2 comments
Language Translations
EdT's picture
+5 5 Votes
Login to vote

My previous article “Adventures with WinPE” which can be found at:

https://www-secure.symantec.com/connect/articles/readyadventures-winpe

was written for WinPE version 2, which is based on the Vista kernel.

With the arrival of Windows 7, Microsoft have released an updated version of WinPE, currently versioned as V3.1, which is based on the Windows 7 kernel.

The objectives of this article are to show how to create a Windows PE 3  iso image, which can then be used to create a WinPE 3 bootable CD or DVD or used with VMWare as a bootable iso image. The associated boot.wim file can also be installed on USB flash memory devices and USB hard disks to create a portable bootable environment that can support all your computer hardware. 

WinPE 3.0 introduces the DISM.EXE tool  (Deployment Image Servicing and Management) as the primary utility for creating the content for the iso and wim files.

However, the procedure outlined for creating the bootable iso in the Microsoft document WinPE.CHM at the default location of: C:\Program Files\Windows AIK\Docs\CHMs  just did not want to work for me, and it took me a while to find the solution.

(At this time I want to point out that the steps I am recording here worked for me, but I offer no warranties that it will work for everyone, so don’t blame me if anything happens to your system. If in doubt, carry out the procedure in a Windows 7 virtual machine – either 32 bit or 64 bit.) 

The process I am going to describe is for a 32 bit WinPE boot system, but the WAIK contains the sources for AMD64 and IA64 boot systems as well, and the process scripts can readily be amended to use these sources instead.

The first step is to download the Windows 7 WAIK, which is currently located at:

http://www.microsoft.com/downloads/details.aspx?FamilyID=696dd665-9f76-4177-a811-39c26d3b3b34&displaylang=en

This will download the file KB3AIK_EN.ISO (1.66Gb), which you can then burn to DVD or alternatively just mount as a virtual DVD using something like the free Virtual Clonedrive utility:  http://www.slysoft.com/en/virtual-clonedrive.html

Then just run the setup of the WAIK from the DVD (real or virtual), and let it install to the default location. (If you choose to install to another folder, you will have to make many edits to the scripts that follow.)  The option to choose from the setup menu is the Windows AIK setup. The other install options are not required for this process.

 While you are doing this, you may also wish to download the SP1 supplement (1.25Gb) from here:
http://www.microsoft.com/download/en/details.aspx?id=5188

Once the WAIK is installed, install the SP1 supplement from the second download. The installation of the supplement is achieved by mounting the ISO, opening an elevated command prompt and typing:

xcopy E:\ "C:\Program Files\Windows AIK\Tools\PETools" /ERDY

where E:\ is the root location of the SP1 supplement.

(The detailed instructions for this supplement can be found here:
http://technet.microsoft.com/en-us/library/dd349350(WS.10).aspx )

Once these steps are completed, locate the file COPYPE.CMD in the folder C:\Program Files\Windows AIK\Tools\PETools, and open it in your favourite text editor.  If performing this task on Windows 7, either turn off UAC, or start Explorer from an elevated command prompt and change permissions on the Windows AIK folder and subfolders to give users full rights, otherwise the changes made in the editor cannot be saved back.

Edit line 65 of COPYPE.CMD from:

echo Updating path to include peimg, cdimage, imagex

to:

echo Updating path to include peimg, cdimage, imagex, dism

Edit line 71 of COPYPE.CMDfrom:

set PATH=%PATH%;%~dp0;%~dp0..\%PROCESSOR_ARCHITECTURE%

to:

set PATH=%PATH%;%~dp0;%~dp0..\%PROCESSOR_ARCHITECTURE%;%~dp0..\%PROCESSOR_ARCHITECTURE%\Servicing

The reason I have made these changes is to avoid errors where the scripts don’t run because DISM.EXE cannot be found. A closer examination of the copype.cmd file reveals that the existing system path is appended to, but of course these changes only apply to the current command window so are transient in nature. Should you wish to be able to type DISM commands from any command window, then the path to DISM.EXE 
(C:\Program Files\Windows AIK\Tools\Servicing) should be added to the system path on your test machine, and the machine rebooted.

To add some useful tools to your WinPE boot image, I now recommend creating a folder called: C:\Program Files\Windows AIK\WinPE3-Utils. 

The contents of this folder will be copied into the WinPE image by my scripts, so place in that folder any programs you may wish to run under WinPE. 

In my folder, I have Ghost32.exe and GImageX.exe in my folder but there are many other useful tools that can be added depending on your individual requirements. Note that the copy operation does not copy subfolders, but if you need to, just use XCOPY instead in the script.

I have also added a colour version of winpe.bmp from a Vista install CD, as the default used is monochrome and looks somewhat boring.

The next step is to create the file Unmount.bat with the following content:

C:
CD "C:\Program Files\Windows AIK\Tools\x86\Servicing"
dism.exe /Unmount-Wim /MountDir:c:\winpe_x86\mount /discard
dism.exe /cleanup-wim
pause              

Save this file somewhere convenient, and run it anytime you have a crashed session creating a WinPE iso file – it does happen, and any future attempts are going to fail if the winpe_x86.wim “template image” is still mounted.

Now we need to create the master script file Make-PE3.bat with the following content:

C:
CD "C:\Program Files\Windows AIK\Tools\PETools"
call copype.cmd x86 c:\winpe_x86
dism.exe /Mount-Wim /WimFile:c:\winpe_x86\winpe.wim /index:1 /MountDir:c:\winpe_x86\mount
dism.exe /image:c:\winpe_x86\mount /Get-Packages
pause
 
dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-hta.cab"
dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-hta_en-us.cab"

REM dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-legacysetup.cab"
REM dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-legacysetup_en-us.cab"

dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-mdac.cab"
dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-mdac_en-us.cab"

dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-pppoe.cab"
dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-PPPOE_en-us.cab"

dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-scripting.cab"
dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-scripting_en-us.cab"

REM dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-setup.cab"
REM dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-setup_en-us.cab"

REM dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-setup-client.cab"
REM dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-setup-client_en-us.cab"

REM dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-setup-server.cab"
REM dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-setup-server_en-us.cab"

dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-wmi.cab"
dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-wmi_en-us.cab"

copy "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" "c:\winpe_x86\mount\Windows\System32"

copy "C:\Program Files\Windows AIK\WinPE3-Utils\*.*" "c:\winpe_x86\mount\Windows\System32"

dism.exe /Unmount-Wim /MountDir:c:\winpe_x86\mount /Commit

copy c:\winpe_x86\winpe.wim c:\winpe_x86\ISO\sources\boot.wim

del /q c:\winpe_x86\iso\boot\bootfix.bin

oscdimg -n -bc:\winpe_x86\etfsboot.com c:\winpe_x86\ISO c:\winpe_x86\Winpe_x86.iso

pause

 

At this point, I will go into some detail as to what the script is doing as this will help users to recover from any errors and also to tailor the script to their specific needs.

1. CD "C:\Program Files\Windows AIK\Tools\PETools"
**Starts you off in the correct folder for copype.cmd

2. call copype.cmd x86 c:\winpe_x86
** Runs copype.cmd to generate an x86 environment in the folder c:\winpe_x86.

If things go badly wrong later and you want to start again, run Unmount.bat then delete the c:\winpe_x86 folder

3. dism.exe /Mount-Wim /WimFile:c:\winpe_x86\winpe.wim /index:1 /MountDir:c:\winpe_x86\mount
** This mounts the “template image” so that you can add packages and other files.

4. dism.exe /image:c:\winpe_x86\mount /Get-Packages
** This reports on any existing packages present in the template image, and is a good check to verify that the template image has mounted correctly. I have put a pause in after this line to allow you to see what is going on before the script moves on to the next part.

5. dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-hta.cab"
5a. dism.exe /image:c:\winpe_x86\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\en-us\winpe-hta_en-us.cab"

** There are a number of pairs of dism commands to Add Packages to the template image – some are remarked out, as they are not too relevant to the utility disk I am building, but the choice is yours – consult the help file WinPE.chm for a detailed description of what each package does, and decide which ones you want to leave in.

Adding these packages in manually from the command line continually resulted in errors, and I believe that the cause of this was the loss of the environment settings created by copype.cmd, as running exactly the same commands from within this script does result in a successful addition of these packages.

6. copy "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" "c:\winpe_x86\mount\Windows\System32"
**This command copies the imagex.exe utility to the boot image. Imagex.exe can create images in much the same way as Ghost, and is useful to have available on any WinPE boot image.

7. copy "C:\Program Files\Windows AIK\WinPE3-Utils\*.*" "c:\winpe_x86\mount\Windows\System32"
**This command copies your utility collection to the WinPE boot image. Just bear in mind that WinPE runs from RAM, so anything you add here, also adds to the size of the WinPE boot image.

8. dism.exe /Unmount-Wim /MountDir:c:\winpe_x86\mount /Commit
** This command finalises the WinPE boot image and unmounts it.

9. copy c:\winpe_x86\winpe.wim c:\winpe_x86\ISO\sources\boot.wim
** This command copies the finalised image to the location from which an ISO will be created, and renames it to boot.wim, which is the standard name for this file in the ISO.

10. del /q c:\winpe_x86\iso\boot\bootfix.bin
** This command is optional, but deleting bootfix.bin will remove the prompt “Press any key to boot from CD or DVD” when the iso image is booting.

11. oscdimg -n -bc:\winpe_x86\etfsboot.com c:\winpe_x86\ISO c:\winpe_x86\Winpe_x86.iso
** This command generates an ISO image of the boot environment you have created, in the form of the Winpe_x86.iso file located in the c:\winpe_x86 folder.

By all means add further pause commands if you want to check that each step completes without error.  The batch script must be run “as administrator” using the right-click mouse option from explorer.

The end result of all this activity can be found in the folder C:\winpe_x86.

The file Winpe_x86.iso can be burned to CD or DVD to provide a bootable WinPE V3 environment.  It can also be used to boot an empty VM. 

Winpe.wim is a copy of the boot.wim file that is located in the ISO\Sources folder.

 

Creating a bootable USB device

32 bit boot

The following procedure applies, with minor differences, to both USB flash memory devices, and USB hard disks. Some command can be abbreviated and where this is possible, the abbreviations are shown in brackets.

  1. Boot your test machine where the WinPE iso image was created, using the Win PE CDROM created as detailed above. Wait until wpeinit has completed and you have a command prompt of: X:\Windows\System32>
  2. Type: DISKPART
  3. Type: LIST DISK (lis dis) and identify the disk number for your USB device. It will typically be Disk 1, so we will continue on that basis
  4. Type: select disk 1 (sel dis 1)
  5. Type: clean
  6. Type: create partition primary (create par pri). If no size is specified, the full device capacity will be used. Otherwise, append: size=(size in Kb)
  7. Type: select partition 1 (sel par 1)
  8. Type: active (act)
  9. For USB hard disks type: format fs=ntfs LABEL="BOOT" QUICK. For USB flash memory devices type: format fs=fat32 LABEL="BOOT" QUICK
  10. Type: assign (ass)
  11. Type: exit

At this point the USB device is ready to receive the Windows PE bootable file image. Verify the drive letter of the USB device, typically F:

At the WinPE command prompt, type:
Xcopy c:\winpe_x86\iso\*.* /s /e /f F:\

(F: is the drive letter which directly references the USB device and should be amended if your USB device mounts on a different drive letter.)

The USB device is now ready to be tested.

Type EXIT at the WinPE command prompt and wait for the system bios message to appear on the test workstation as it reboots. Press the appropriate function key to allow selection of the boot device, and when the boot list is displayed, select the USB device and boot from it. If all went well, the standard WinPE boot should commence. Wait until the X:\Windows\System32> prompt is displayed, and then type EXIT to reboot your system, as the boot test is now complete.

Comments 2 CommentsJump to latest comment

Newton's picture

Hi,

Is there a command to invoke WinPE image regeneration in Altiris?

I have a requirement of custom SAN policies on the WINPE image.

Usually i mount the WINPE.WIM with help of IMAGEX (similar to DISM.EXE) change the policies, and from Altiris deployment console "PXE Config Utility -> Boot menu regenerate the WinPE image.

Now, is there a way to invoke WinPE regeneration with help of command?

I am working on an automation and regeneration WinPE via command would be of much help.

 

Thanks

0
Login to vote
Newton's picture

Found this URL, and it has the info what i am looking for, will checkout

https://www-secure.symantec.com/connect/articles/a...

 

 

0
Login to vote