Using Windows PE in Windows XP Embedded Development

 

Microsoft Corporation

March 2004

Applies to: All versions of Microsoft® Windows XP® Embedded

Summary

The Microsoft® Windows® Preinstallation Environment (Windows PE) CD-ROM provides a small but powerful boot environment that you can use for many Windows XP Embedded development tasks.

With Windows PE you can bring up a device that has no operating system, hard drive, or device list. The following list shows some of what you can do with Windows PE:

  • Boot any device that has a CD-ROM drive, regardless of the state or presence of boot media, such as a hard drive.
  • Detect hardware devices with Target Analyzer.
  • Format and partition a hard drive with DiskPart.
  • Connect to network folders to install drivers or an image.

After you have created an image, you can use Windows PE to fine tune the image on your device. The following list shows some of what you can do with Windows PE after you have created an image:

  • Use Windows PE as an emergency boot disk.
  • Fix a corrupt boot.ini file.
  • Access the file system on your target device.
  • View and edit the registry hive for your image on the target device before or after running the image.

This technical article is written for Microsoft partners who develop and deploy Windows XP Embedded images, and assumes a working knowledge of, and a proficiency with, Microsoft Windows Embedded Studio - Component Designer, Component Database Manager, and Target Designer.

You can also use Windows PE on a recovery CD, to restore, deploy, or upgrade an image in the field. For more information, see Creating an Embedded Recovery CD by Using Windows PE and SDI.

Contents

Introduction to Windows PE
Boot with Windows PE
Detect hardware devices with Target Analyzer
Use DiskPart to partition a hard drive
Connect to network folders to install drivers or an image
Use Windows PE as an emergency boot disk
Access the file system on your target device
View and edit the registry hive for your image on the target device
Limitations
Windows APIs That Are Not Supported on Windows PE

Introduction to Windows PE

Microsoft Windows Preinstallation Environment (Windows PE) is a minimal Win32® subsystem with limited services, based on Windows XP Professional running in protected mode. Windows PE provides the minimal functionality that you need to:

  • Run Windows Setup.
  • Install an operating system from a network share.
  • Automate basic processes.
  • Perform hardware validation.

The Windows PE CD-ROM supplied with Windows XP Embedded Studio provides the following features:

  • A hardware-independent Windows environment with a small footprint both on the bootable media and in memory.
  • A subset of the Win32 application programming interfaces (APIs), a command-line interface (Cmd.exe) capable of running batch files, and support for Windows Script Host (WSH), HTML Applications (HTA), and ActiveX Data Objects (ADO) used to create custom tools or scripts.
  • Network access and support for standard in-box network drivers that may be required for copying images and test suites from a network that uses TCP/IP.
  • Support for all mass-storage devices that use Windows 2000 or Windows XP drivers.
  • Native support to create, delete, format, and manage NTFS file system partitions.
  • Hardware diagnostics to load and test specific hardware drivers.

Boot with Windows PE

Because Windows PE is self-contained on the CD-ROM, you can boot your device without using a hard drive. Once you have booted from Windows PE, you can run Target Analyzer, access files on the device, and connect to network folders.

To boot by using Windows PE

  1. Connect a CD-ROM drive to your device.

  2. Insert the Windows XP Embedded CD-ROM Disc 1 in the drive.

  3. Configure your device's BIOS setting to boot from the CD-ROM drive and boot the CD.

    Windows PE starts. During the Windows PE boot process, networking services are enabled and the network interface is configured through DHCP.

Detect hardware devices with Target Analyzer

Windows PE uses Plug and Play to enumerate the hardware on your target device. Target Analyzer can then use this information to create the devices.pmq file.

Running TAP.exe in the Windows PE environment usually results in a fairly minimal PMQ or hardware profile of the target system. This leads to a minimal configuration run-time image.

The following table shows the differences in the number of devices that TAP.exe will find on various environments:

Device Full desktop environment Windows PE environment
Typical Windows XP Pro or Windows 2000 Desktop 65-75 devices 35-45 devices
Typical Windows XP Pro or Windows 2000 Laptop 90-100 devices 45-55 devices

In the Windows PE Environment, TAP.exe will find the following essential items for your devices.pmq:

  • All of the core parent devices such as Peripheral Component Interconnect (PCI) and Accelerated Graphics Port (AGP) devices.
  • The correct system hardware abstraction layer (HAL).
  • Disk drives.
  • CD-ROM drives.
  • System chipsets.
  • Critical boot devices required to start the system.
  • Basic universal serial bus (USB) device support.

To use Windows PE to run Target Analyzer

  1. Set up your device with all of the peripherals you intend the device to have in its final configuration.
  2. Connect a CD-ROM drive to your device.
  3. Boot the device with Windows XP Embedded CD-ROM Disc 1.

When you run Target Analyzer from Windows PE, you can save the output (devices.pmq) to either a network folder or a floppy drive.

To save the Target Analyzer output to a network location

  1. From the Windows PE command line, use the net use command to map a shared drive to the device.

    The following code example shows the general syntax.

    net use * \\<computername>\<sharename> 
    

    The following code example shows how to map the shared C drive of the computer named "development_computer" to the "z" drive on your target device.

    net use Z \\<developmentcomputer>\<C$> 
    
  2. Change directories to the drive letter you just mapped.

    For example type:

    z:

  3. Change directories to the directory that contains Tap.exe.

    For example type:

    cd Program Files\Windows Embedded\utilities
    
  4. Run Tap.exe.

    The default location and file name for the output file is the same directory as tap.exe, and the file is named devices.pmq.

    **Note   **You can specify a different path and output file name with the switch o/. For example, to send the output to the directory c:\Device1 on the computer //OtherDevelopmentComputerName, with the output file name devices2.pmq, type:

    tap.exe /o //<OtherDevelopmentComputerName>/c$/Device1/devices2.pmq 
    

To save the Target Analyzer output to a floppy drive

  1. Navigate to the \XPE directory and run TAP.exe from the command line.

    The following code example shows the appropriate parameters:

    tap /O a:\Kiosk-HW.PMQ
    

    TAP.exe will then produce a hardware profile, a .pmq file, of the target device and save the results of the results to a:\Kiosk-HW.PMQ on drive A.

  2. Copy the Kiosk-HW.PMQ file to your development computer where you have installed the Windows XP Embedded Tools and Database.

Use DiskPart to partition a hard drive

DiskPart is included with Windows PE, and can be used to configure a device that does not have an operating system (OS). After booting Windows PE, you can configure the hard disks on your system.

Additional information about using Diskpart is available at this Microsoft Web site.

To configure a hard drive by using DiskPart

  1. Boot Windows PE on the device.

  2. At the command prompt, type DiskPart. The DiskPart command prompt is displayed.

  3. To display the DiskPart help, type ?.

  4. Use the DiskPart commands to list the current configurations, select a disk, or edit a partition.

    For example, to create a 400 MB primary partition on the second disk in your system, use the following Diskpart commands:

    list disk
    select disk 1
    list partition
    create partition primary size=400
    
  5. After you configure the hard disk, stop the utility by typing exit.

  6. Reboot the device.

  7. Format any newly created partitions with the format command. For more information about using format, see this Microsoft Web site.

Note   The DiskPart utility includes an override option. This option can be used to delete a Microsoft Reserved (MSR) partition or another protected partition. Use extreme caution when using the override option.

You can also create a script for DiskPart by using the commands needed to deploy mass systems. If you boot Windows PE and bring the device up on the network, you can run a DiskPart script by using the following command:

diskpart /s<script name>

Connect to network folders to install drivers or an image

You can use Windows PE to connect a device that has no operating system (OS) to the network. Windows PE supports many standard network devices. When you boot with Windows PE, it enables the network and starts Dynamic Host Configuration Protocol (DHCP). When your device is active on the network, you can map shared drives or copy run-time images and applications to the device.

To map a shared drive

  1. Boot Windows PE on the device.

  2. From the Windows PE command line, use the net use command to map a shared drive to the device.

    For example, net use * \\<computername>\<sharename>.

    After the shared drive is mounted on the device, you can copy run-time images from the share to the device, or run remote scripts.

Use Windows PE as an emergency boot disk

If you make changes to your device that make the device unbootable, you can use Windows PE as an emergency boot disk.

For example, you might do this if you deploy an image to a dual-boot test device and you accidentally overwrite your test machine's boot.ini file with your image's boot.ini file. If you cannot start your computer, you can boot from the Windows PE CD-ROM and fix the boot.ini file.

To fix your boot.ini file

  1. Boot the device with Windows XP Embedded CD-ROM Disc 1.

  2. After Windows PE starts, at the command prompt type:

    C:\boot.ini

  3. Edit the boot.ini file as needed.

    For more information about editing your boot file, see this Microsoft Web site.

Access the file system on your target device

When you boot your device with Windows PE, you have complete access to the NTFS file system on the target device, regardless of administrator privileges, access control lists, or NTFS permissions placed on the file system.

**Note   **You can encrypt files and folders on your image with Encrypted File System (EFS) to help secure data against unauthorized access. Encrypted files are protected against NTFS access. For more information about EFS, see this Microsoft Web site.

To access files on your target device

  1. Boot the device with Windows XP Embedded CD-ROM Disc 1.

    Windows PE starts.

  2. At the command prompt, map network drives as you need, and then navigate to local or network folders.

View and edit the registry hive for your image on the target device

You can view and edit the registry hive for your image on your device, before or after FBA. The registry files are located in the \WINDOWS\system32\config folder of your target device.

For example, C:\WINDOWS\system32\config.

Before you run FBA, registry files have a .SAV extension. The following list shows the registry hives with the extension:

  • SAM.SAV
  • SECURITY.SAV
  • SOFTWARE.SAV
  • SYSTEM.SAV

When FBA completes, the registry files are saved without the .SAV extension. The following list shows the registry hives without the extension:

  • SAM
  • SECURITY
  • SOFTWARE
  • SYSTEM

For more information about registry hives, see this Microsoft Web site.

To edit the registry of your target device

  1. Boot Windows PE on the device.

  2. At the command prompt, type regedit.

  3. Click HKEY_LOCAL_MACHINE.

  4. On the File menu, choose Load Hive.

    A series of message boxes may appear that state that the folder cannot be found and that the location is unavailable. Ignore these messages and click OK when they appear.

    The Load Hive dialog box appears.

  5. In the Files of type box, select All Files.

  6. Navigate to the registry location on your target device.

    For example, if your image is on drive C, navigate to C:\WINDOWS\system32\config.

  7. In the config folder, select the hive you want to edit and then choose OK.

  8. In the Load Hive dialog box type a Key Name. For example, TEST_DEVICE.

    Repeat the previous steps as needed to load more hives.

  9. Choose HKEY_LOCAL_MACHINE, and then choose the new reg key(s) you created.

  10. Edit or view the reg keys.

  11. When you have completed your reg key changes, choose HKEY_LOCAL_MACHINE, choose the File menu, and then choose Unload Hive.

Limitations

Windows PE as it is included on the Windows Embedded CD-ROM has the following limitations:

  • The version of Windows PE included on the Windows XP Embedded CD-ROM cannot be updated or configured. You must purchase a licensed version of Windows PE to add custom support. For information, contact your Microsoft distributor.
  • Windows PE includes only a subset of the available Win32 APIs. Included are I/O (disk and network) and core Win32 APIs.
  • Windows PE automatically stops running the shell and reboots after 24 hours of continuous use.
  • There is no network access to files or folders on a Windows PE computer from another location on your network.
  • Distributed File System (DFS) name resolution is not supported. There is limited support with Windows PE 1.1 but only for standalone DFS roots.
  • The tested methods of gaining network connectivity to file servers are TCP/IP and NetBIOS over TCP/IP. Other methods, such as the IPX/SPX network protocol, are not supported.
  • The drive letters assigned during Windows PE are not saved to any registry that persists when you reboot. The drive letter assignment when you create partitions is in the order of creation, but the drive letter assignments when you reboot will be in the default order.
  • Windows PE requires a VGA-compatible device and uses a screen resolution of 800 x 600 pixels. If Windows PE cannot detect video settings, the default screen resolution is 640 x 480 pixels.
  • Windows PE does not support the Microsoft .NET framework.

**Note   **If you need more functionality than is offered by Windows PE, you can create your own Windows XP Embedded image that boots from a CD. For more information about creating a bootable CD-ROM, see this Microsoft Web site.

Windows APIs That Are Not Supported on Windows PE

The following categories of functions of the Win32 API set are not present in Windows PE:

  • Windows Management Instrumentation (WMI)
  • Windows Multimedia
  • Still Image
  • OpenGL
  • NetShow Theater Administration
  • Windows Shell
  • Access Control
  • Power Options
  • Printing and Print Spooler
  • Window Station and Desktop
  • Terminal Services
  • User Profile
  • Tape Backup

For more information on these categories, see this Microsoft Web site.