customizing windows pe

11
 Customizing WinPE Page 1 of 11 Built by HynesITe, Inc www.hynesite.biz | see what’s possible Customizing Windows PE Abstract WinPE is the Windows Preinstallation Environment. Windows PE 2.0 is the core deployment foundation for Windows Vista and is available to all Windows Vista customers. It is a minimal Win32 subsytem and it is based on the Windows kernel running in protected. WinPE is easily configured and extended using ImageX. Windows PE enables users to inject drivers, configure Windows Vista offline, provide recovery solutions as well as diagnose and troubleshoot system problems. WinPE is designed to make large-scale, customized deployments of the new Windows Vista operating system notably easier. It is ideal for the following scenarios:  Booting a computer that does not have an operating system  Creating and formatting partitions on a hard disk  Installing Windows from a network share  Booting a computer with a corrupted operating system Objectives This lab covers the following activities:  Customize components included in WinPE  Automating tasks in WinPE  Creating a bootable WinPE iso image  Updating a Windows Deployment Server (WDS) to include a WinPE boot image. Scenario In response to growing frustrations as a result of your organization’s existing solut ions for booting new machine builds, and a need to provide a simple & robust platform for resolving issues with Windows XP, Vista and servers, you have bee n given the responsibility for creating a solution. Discussions with the desktop build team have revealed that their primary issue is locating DOS drivers for network cards. They have also asked for the abil ity to create and format partitions with NTFS. Support for scripting was also mentioned as being highly desirable. The support teams have requested a tool that will allow them to recover machines that have suffered issues such as corrupted boot sectors & partition tables, or damaged operating system files, as well as to perform maintenance tasks such as defragmenting volumes and running virus scans. After reviewing the information gathered from the various teams, WinPE has been identified as the ideal solution. In this lab you will use the tools from the Windows Automated Installation Kit (Windows AIK) to create and modify a WinPE image that will fulfill the needs of the teams in your organization. Background Information

Upload: ikmal-said

Post on 07-Oct-2015

15 views

Category:

Documents


0 download

DESCRIPTION

Customize Windows Pre-installed Environment (WinPE) the way you want, whether for recovery purposes or own experiments!

TRANSCRIPT

  • Customizing WinPE Page 1 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    Customizing Windows PE

    Abstract WinPE is the Windows Preinstallation Environment. Windows PE 2.0 is the core deployment foundation for Windows Vista and is available to all Windows Vista customers. It is a minimal Win32 subsytem and it is based on the Windows kernel running in protected. WinPE is easily configured and extended using ImageX. Windows PE enables users to inject drivers, configure Windows Vista offline, provide recovery solutions as well as diagnose and troubleshoot system problems. WinPE is designed to make large-scale, customized deployments of the new Windows Vista operating system notably easier. It is ideal for the following scenarios:

    Booting a computer that does not have an operating system Creating and formatting partitions on a hard disk Installing Windows from a network share Booting a computer with a corrupted operating system

    Objectives This lab covers the following activities:

    Customize components included in WinPE Automating tasks in WinPE Creating a bootable WinPE iso image Updating a Windows Deployment Server (WDS) to include a WinPE boot image.

    Scenario In response to growing frustrations as a result of your organizations existing solutions for booting new machine builds, and a need to provide a simple & robust platform for resolving issues with Windows XP, Vista and servers, you have been given the responsibility for creating a solution.

    Discussions with the desktop build team have revealed that their primary issue is locating DOS drivers for network cards. They have also asked for the ability to create and format partitions with NTFS. Support for scripting was also mentioned as being highly desirable.

    The support teams have requested a tool that will allow them to recover machines that have suffered issues such as corrupted boot sectors & partition tables, or damaged operating system files, as well as to perform maintenance tasks such as defragmenting volumes and running virus scans.

    After reviewing the information gathered from the various teams, WinPE has been identified as the ideal solution. In this lab you will use the tools from the Windows Automated Installation Kit (Windows AIK) to create and modify a WinPE image that will fulfill the needs of the teams in your organization.

    Background Information

  • Customizing WinPE Page 2 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    The following virtual machines will be used to complete this lab: VistaLabs_DC1: Domain Controller running Windows Server 2003 VistaLabs_Client1: Windows Vista client machine

    Prerequisites You should be familiar with the following products or technologies before you begin this lab.

    Experience working with Windows device drivers Ability to analyze command line commands and understand syntax Familiarity with scripting using WSH and VBScript.

    Duration 60 Minutes

    For More Information http://www.microsoft.com/technet/windowsvista/deploy/winpe.mspx Microsoft BCD FAQ http://tinyurl.com/naasp

    Support Information This lab is built and supported by HynesITe, Inc. See whats possible at www.hynesite.biz.

  • Customizing WinPE Page 3 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    Exercise 1 Build a custom WinPE image

    Microsoft Windows Pre-installation Environment (Windows PE) 2.0 is a bootable tool that provides operating system features for installation, troubleshooting, and recovery.

    With an average size of 130Mb for an x86 build, WinPE can be booted from removable media such as USB keys, CDR or used as part of a PXE (F12) boot solution.

    In this exercise you will create a WinPE image by extracting the source files to the local disk of your workstation, modify the standard components included in the build to provide support for the needs of the build team by including additional device drivers and support for scripting, and support for the support teams by including the Recovery tool package. Once this is done you will then prepare the build files and generate a Windows Image (WIM) file that can then be used to create a series of boot solutions.

    Note: All tasks should be performed using the DC1 virtual machine

    Use ImageX.exe to extract the contents of a WIM file to a folder In this task you will create the basic folder structure required for building WinPE images and then extract the contents of WinPE.wim file that is provided with the Windows Automated Installation Kit (WAIK)

    1. Log on to DC1 as [email protected] with a password of P@ssw0rd.

    2. Using Windows Explorer, create the following folders:

    C:\winpebuild C:\winpe\sources C:\winpe\boot

    3. Open a Command Prompt, change to the C:\Program Files\Windows AIK\Tools\x86 directory.

    4. In the Command Prompt, type the following command and then press ENTER.

    ImageX /info "C:\Program Files\Windows AIK\Tools\PETools\x86\winpe.wim"

    Review the details of the image contained in the WIM file and confirm that it is a WinPE image and that it has been compiled for use on an x86 platform. You can find this information in the section of the output approximately 3 lines from the top.

    WinPE is available for both 32bit (x86) and 64bit (x64) platforms.

    5. Open a Command Prompt, type the following command and then press ENTER.

    ImageX /apply "C:\Program Files\Windows AIK\Tools\PETools\x86\winpe.wim" 1 C:\winpebuild

  • Customizing WinPE Page 4 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    Note: In the preceding command, you are applying the winpe.wim file to the c:\winpebuild directory you created earlier. The 1 in the command is the index number of the image within this WIM file. A single WIM file can contain multiple images, so we use an index number to differentiate between them.

    6. Using Windows Explorer, browse to the C:\winpebuild folder and confirm that the following folders have been created:

    C:\winpebuild\Program Files C:\winpebuild\Users C:\winpebuild\Windows

    Explore the WinPE image using the PEimg.exe utility Now that the source files have been extracted, the PEimg.exe tool can be used to modify the components that are included in the WinPE image. In this task you will use the /list option to discover the packages that are available in the WinPE build you extracted in the previous task.

    7. In the Command Prompt, change to the C:\Program Files\Windows AIK\Tools\PETools directory.

    8. Enter the following command to list the components that are available for installation.

    peimg c:\winpebuild\windows /list

    9. Review the output and notice the names of the packages included in this WinPE image. You will refer to these names in the next step.

    Note: In the output, the + or symbol in the Ins column indicates the installation flag on the package. + indicates the package will be installed, - indicates it will not be installed.

    Enable components in the WinPE image After reviewing the packages available, you have decided to include the HTA, SRT and scripting packages. The HTA package provides support for HTML Applications (HTA) which will allow the build teams to display HTML content during the build process that will be used to provide users with information on the new environment. The SRT (Server Recovery Tools) package will provide the support teams with the recovery tools that can be used to repair failed installations, while the Scripting package supports the use of VBscript to automate tasks in the WinPE environment.

    1. In the Command Prompt enter each of the following as separate commands to install the specified packages:

    peimg c:\Winpebuild\Windows /install=winpe-hta-package

    peimg c:\Winpebuild\Windows /install=*SRT*

    peimg c:\Winpebuild\Windows /install=winpe-Scripting*

    2. Once the previous task has been completed, enter the following command to confirm that the packages have been successfully installed:

  • Customizing WinPE Page 5 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    peimg c:\winpebuild\windows /list

    Note: A + next to a package indicates that it is included in the build

    Install an additional device driver offline In this task you will use the PEIMG.EXE utility to inject a driver into the WINPE build. This will result in the driver being permanently added to the build. For scenarios where you would like to test a new driver with out permanently adding it to the build, the DRVLOAD.EXE tool could be used once WINPE has booted to load a device driver for the duration of the session

    1. In the Command Prompt, type the following command and then press ENTER

    Peimg /inf="E:\sources\Out-of-Box Drivers\wireless\w29n51.inf" c:\Winpebuild\Windows

    2. Review the output from the command and confirm the operation has been completed successfully.

    Capture the WinPE build prior to prepping the image Now that the image has been modified, you are ready to prepare the image for capture. As part of this process, the image will no longer be able to be modified, so it is recommend that you create a copy of the build directories so that they can be restored if required. One of the simpler methods to do this is to use the ImageX.exe tool and save it as a WIM file. The following task will capture the existing WinPE build directory and store it in a WIM file.

    1. Open a Command Prompt, and change to the C:\Program Files\Windows AIK\Tools\x86, folder and type the following command and then press ENTER.

    ImageX /boot /compress maximum /capture c:\Winpebuild c:\customwinpe.wim Custom WinPE image

    2. In a typical environment, you would let this process complete and then archive the customwinpe.wim for future reference. Because this process will take approximately 15 minutes in this lab environment, press CTRL + C to abort the image creation process.

    Prepping a WinPE build

    In this exercise you will examine the size of the unprepared image, prepare the image, and then compare the size of the final image.

    1. In the Command Prompt, type the following commands and then press ENTER.

    Dir c:\winpebuild /s >c:\unprepped.txt

    Notepad c:\unprepped.txt

    2. When notepad opens, scroll to the end of the file and take note of the total number of files and the file size. When you are finished, close Notepad.

    3. In the Command Prompt, change back to the C:\Program Files\Windows AIK\Tools\PETools directory and type the following command and then press ENTER.

  • Customizing WinPE Page 6 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    Peimg c:\Winpebuild\Windows /Prep /F

    Note: The /F switch is used to remove the prompt confirming that you wish to prepare the image.

    4. Repeat steps one and two to compare the total number of files and bytes of the directory once the image has been Prepped

    Building a WinPE image

    Once the WinPE build has been customized and prepped, it is now ready to be captured and stored as a WIM file. In the following task you will use IMAGEX.EXE to create a WIM file that can then be used with OSCDIMG.EXE utility to create a bootable CD, added to a WDS server for use with PXE boot services or added to the local machine as a boot option.

    1. In the Command Prompt, switch back to the C:\Program Files\Windows AIK\Tools\x86 directory and type the following command and then press ENTER.

    ImageX /boot /compress maximum /capture c:\Winpebuild c:\winpe\sources\boot.wim Custom WinPE Boot image

    Note: The above should be entered as a single command and will take approximately 5 minutes to complete.

    2. Once the BOOT.WIM file has been successfully created, create a folder named E:\SOURCES\CUSTOM and copy the BOOT.WIM file from C:\WinPE\sources into it.

    Building a bootable CD image.

    In this task you will use the OSCDIMG.EXE utility to create a bootable CD image. Once the ISO file has been created, it can then be burned to physical media,

    1. In the Command Prompt, enter the following command to copy the contents of the c:\Program Files\Windows AIK\Tools\x86\Boot folder to the C:\winpe\boot folder.

    xcopy "c:\program files\windows aik\tools\PETools\x86\boot" c:\winpe\boot /cherky

    2. Copy c:\Program Files\Windows AIK\Tools\PETools\x86\Bootmgr to the c:\winpe folder

    3. Confirm that the boot.wim file is located in the c:\winpe\sources folder

    4. Change back to the C:\Program Files\Windows AIK\Tools\PETools directory and then enter the following command

    OSCDIMG n b"c:\program files\windows aik\tools\PETools\x86\boot\etfsboot.com" c:\winpe e:\sources\winpe.iso

    Note: There is a space after n, but there is NOT a space after b. In this command the n is being used to allow long file names, the b is being used to specify the El Torito boot sector file as the path\etfsboot.com, and we are creating an ISO file called winpe.iso that will be created in the E:\Sources directory.

  • Customizing WinPE Page 7 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    5. Using Windows Explorer, confirm that the E:\sources\winpe.iso file has been successfully created.

    Note: This ISO file can now be burned onto a CD using CD burning software, and your workstations can now be booted using this new CD-ROM.

  • Customizing WinPE Page 8 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    Exercise 2 Booting from a Custom WinPE WIM File

    Now that you have created the BOOT.WIM file, you will use a Windows Vista Client to test the WinPE image. By using a Windows Vista client, it is possible to copy the WIM file to the local hard disk and then boot from it, thereby removing the need to build an ISO file and burn it to a CD or to upload the image to a WDS server in order to PXE boot. This can result in significant time savings when a build is undergoing development and testing.

    The ability to boot from a WIM file in Windows Vista is provided by the new boot manager application, the BCD. The Boot Configuration Data store, stores the configuration entries for the various operating systems that are installed on the machine and replaces the BOOT.INI file that has been used in previous versions of Windows. As an administrator, you can use the BCDEDIT.EXE utility to view and modify the BCD entries on Windows Vista or later. Alternatively, you can develop your own tools to manage the BCD store by using the BCD WMI provider interface.

    Note: All tasks should be performed using the Client1 virtual machine

    Copy support files from DC1 to CLIENT1

    In this task you will copy the BOOT.WIM file created in Exercise 1 from DC1 to Client1 so that it can then be used to boot WinPE on Client1 as well as the wireless driver files for use in this lab

    1. Log on to CLIENT1 as [email protected] with a password of P@ssw0rd.

    2. Click on the Start menu and in the Start Search box type cmd and then press ENTER.

    3. Type md c:\winpe to create a folder named C:\WinPE

    4. Type copy \\dc1\sources\custom\boot.wim c:\winpe to copy the BOOT.WIM file from \\DC1\Sources\Custom to C:\WinPE

    5. Type md c:\winpe\wireless to create a wireless directory.

    6. Type copy \\dc1\sources\Out-Of-Box Drivers\Wireless C:\winpe\Wireless to copy the contents of the Wireless folder from \\DC1\Sources\Out-of-Box Drivers to C:\Winpe\Wireless

    Creating a RAMDISK option in the BCD database.

    As part of the WinPE boot process, a ramdisk will be created that will be used to store the WinPE files. In this task you will use the BCDEDIT.EXE tool to create BCD entries that will define the standard parameters for the RAMDISK

    1. Open a Command Prompt and type each of the following commands.

    bcdedit /create {ramdiskoptions} /d "Ramdisk options"

    bcdedit /set {ramdiskoptions} ramdisksdidevice partition=C:

    bcdedit /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi

  • Customizing WinPE Page 9 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    2. In Command Prompt, type the following command to create a new boot application

    bcdedit /create /d "WinPE Full" /application OSLOADER

    3. The output will contain a new guid value for the boot application entry and appear similar to the following:

    The entry {YourGUID} was successfully created.

    You must use the new guid in the remaining Bcedit commands. To copy your GUID in the Command Prompt, right click the Command Prompt window and click Mark. Highlight your GUID and then press enter. You can then right click the Command Prompt window and click paste to reuse your GUID.

    4. In Command Prompt, type the following commands to configure the parameters for the WinPE boot entry. There are six commands to enter; the longer commands appear on two lines because they are wrapped to fit the page. When you have finished typing each command, press ENTER. Where you see {putYourGuidHere} you should insert your GUID from the previous step. To do this in a Command Prompt window, right click and click paste.

    bcdedit /set {putYourGuidHere} device ramdisk=[c:]\winpe\boot.wim,{ramdiskoptions}

    bcdedit /set {putYourGuidHere} path \windows\system32\winload.exe

    bcdedit /set {putYourGuidHere} osdevice ramdisk=[c:]\winpe\boot,{ramdiskoptions}

    bcdedit /set {putYourGuidHere} systemroot \windows

    bcdedit /set {putYourGuidHere} winpe yes

    bcdedit /set {putYourGuidHere} detecthal yes

    5. In Command Prompt, type the following command to add WinPE to the boot menu. When you have finished typing the command press ENTER.

    bcdedit /displayorder {putYourGuidHere} /addlast

    At this point, your machine has the new entry WinPE Full in the boot menu.

    6. Copy Boot.sdi file from \\DC1\C$\Program files\Windows AIK\tools\PETools\x86\boot\ to C:\boot by typing in the Command Prompt window xcopy \\dc1\c$\program files\windows AIK\tools\PETools\x86\boot\boot.sdi c:\boot and then press Enter.

    7. Reboot Client1 and notice the WinPE Full entry from the boot menu. Do not select it as the rest of this lab will be done from within Windows Vista. Hint: To reboot client1 click the arrow next to the lock on the start menu. If Press any key to boot from CD or DVD prompt appears, ignore this message and DO NOT PRESS any key.

  • Customizing WinPE Page 10 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    Exercise 3 Customizing the WinPE Startup

    In this exercise you will configure an Unattend.XML file to configure startup actions to occur once Windows PE has been booted. For this exercise , the startup action will utilize the HTML Application (HTA) functionality you added to your WinPE build in Exercise 1 to launch a welcome screen. This welcome screen could be used to run custom actions, or display information to the end user.

    Note: All tasks should be performed using the Client1 virtual machine

    Open Windows PE for modification using ImageX In this task you will use IMAGEX.EXE to mount the BOOT.WIM file so that you can add the UNATTEND.XML file to the image.

    1. Log on to Client1 as [email protected] with a password of P@ssw0rd.

    2. Click on Start, point to All Programs, point to Accessories, and then click Command Prompt.

    3. In the Command Prompt, change to the C:\Program Files\Windows AIK\Tools\x86 directory.

    4. In the Command Prompt, type each of the following commands and then press ENTER.

    Md c:\mountPE

    ImageX /mountrw c:\winpe\boot.wim 1 c:\mountPE

    5. Copy the WINPE-UNATTEND.XML file from \\DC1\SOURCES\WINPE to the C:\MOUNTPE folder and rename it to UNATTEND.XML

    6. Using Notepad, create a new file and save it as C:\MOUNTPE\WELCOME.HTM

    7. In Notepad, add the following line of text and then save and close the file

    Welcome to Windows PE

    8. Using Notepad, open the C:\MOUNTPE\UNATTEND.XML file.

    9. In the UNATTEND.XML file, locate the node and replace the text InsertTextHere with MSHTA x:\welcome.htm

    10. Locate the node and replace the text InsertTextHere with Welcome to Windows PE

    11. Save the document and then close Notepad.

    12. In the Command Prompt, change to the C:\Program Files\Windows AIK\Tools\x86 directory.

    13. In the Command Prompt type the following command and then press ENTER.

  • Customizing WinPE Page 11 of 11

    Built by HynesITe, Inc www.hynesite.biz | see whats possible

    ImageX /Commit /UnMount c:\mountPE

    Note: The IMAGEX /Commit /Unmount task is used to save the changes made to the BOOT.WIM file and then dismount the file.

    14. In a production environment when you restart your machine and select the WinPE FULL boot entry, the welcome screen is launched when WinPE starts.