Delen via


Step-by-Step: Windows 8 Deployment for IT Professionals

Applies To: Windows 8, Windows 8.1

This guide describes an end-to-end process for IT professionals to capture, customize and deploy Windows® images for use in enterprise organizations.

Important

If you are new to Windows deployment, we recommend the Microsoft Deployment Toolkit (MDT) for IT professionals who want to customize and deploy Windows in their organizations. This tool provides an easy-to-use user interface and automates many of the tasks that are required to deploy Windows. For more information, see Microsoft Deployment Toolkit.

This guide uses the tools included in the Windows Assessment and Deployment Kit (Windows ADK). This includes Windows System Image Manager (Windows SIM), the Deployment Imaging Servicing and Management tool (DISM), and Windows Preinstallation Environment (Windows PE). In addition to the tools that this guide describes, other tools are available in the Windows ADK that you can use to prepare your organization for migrating to Windows 8 and Windows 8.1:

You can use the tools that the Windows ADK includes in the following Windows deployment scenarios:

  • Highly customized environment

    For organizations that want a high degree of control and automation for their Windows deployment, the Windows ADK provides flexibility and control over the images that you create and how you deploy them. You can control all of the different configurable settings in Windows, script your own deployment requirements, and control the end-to-end deployment of your Windows images.

  • Standard image installation

    If your organization uses a standard Windows image across all hardware, such as a call center office, you can use the Windows ADK to streamline basic deployment of this image.

In This Guide

  • Preparation

  • Step 1: Install Windows Preinstallation Environment

  • Step 2: Create and Modify Answer Files

  • Step 3: Use the Answer File to Install Windows

  • Step 4: Capture the Image

  • Step 5: Deploy Windows to Test Computers

Preparation

This guide assumes that the computers, applications, devices, and settings in your organization can run Windows 8.1.

Computers

This guide requires several different computers to test deployment:

  • The technician computer: The computer on which you will install the Windows Assessment and Deployment Kit (Windows ADK).

Note

We recommend that you use the 32-bit version of Windows on the technician computer because the 32-bit version supports both 32-bit and 64-bit deployments.

  • The reference computer: A computer that represents any computer in your organization.

    For this computer, choose a design that does not require special drivers or hardware configurations. The design must include at least one available USB port.

  • The test computer: A computer where you test the operating system and assess compatibility. This computer must have a hardware design that matches specific computer hardware in your organization.

    To complete this guide, you can use the same computer for both the reference computer and the test computer, or you can use different computers.

Other hardware

In addition to the computers, you need the following hardware:

  • An empty USB flash drive that has at least 4 gigabytes (GB) of free space. You will load Windows Preinstallation Environment (Windows PE) on this USB flash drive. Windows PE is used to boot the computer to a simple command prompt from which you can capture and deploy images and run deployment scripts. You can also use this same drive to store the answer file that Windows uses during unattended installation.

  • An external storage device that has at least 8 GB of free space. This can be a second USB flash drive, an external USB hard disk drive, or a network location.

    Windows image files sometimes exceed the 4 GB limitation of FAT32. Therefore, the external storage devices that are larger than 4 GB must use the NTFS file system so that the drive can store Windows image files. This guide assumes that the external storage device is an external USB hard disk drive.

    To use a network location as the external storage device, map a drive to the network location by using the following command before you perform each step that uses the external drive:

    net use e: \\server\share

Software

You need the following software:

  • A Windows product DVD and product key.

  • The Windows ADK.

    Download the Windows ADK. Install the Deployment Tools and Windows Preinstallation Environment.

  • Any drivers or packages that are required to boot your reference computer or test computer.

Note

The packages must match the architecture of the Windows operating system. For example, if the computer has a 64-bit processor, you must install 64-bit driver packages.

Step 1: Install Windows Preinstallation Environment

In this section, you install Windows PE on a USB flash drive. Windows PE is a minimal operating system that can be used to help install Windows, and to capture, maintain, and deploy Windows images.

1.1 Prepare the Windows PE files

  1. On the technician computer, open the Deployment and Imaging Tools Environment command prompt.

    Click Start, and type deployment. Right-click Deployment and Imaging Tools Environment and then select Run as administrator.

  2. Run the following command to copy the base Windows PE files into a new folder:

    copype amd64 C:\winpe_amd64
    

1.2 Add drivers or packages to Windows PE (optional)

  1. If your reference computer requires boot-critical drivers, you can modify the Windows PE base-image file to include these drivers. You can use the same driver packages for Windows PE that you use for Windows 8.1.

Note

You often do not need to add drivers and packages. Windows PE includes generic drivers and packages that work on many common hardware configurations.

Use the DISM tool to *mount* the Windows PE base-image file. Mounting an image file unpacks the file contents into a folder so that you can make changes directly or by using tools such as DISM. To mount the image file, run the following command:

    Dism /mount-image /imagefile:c:\winpe_amd64\media\sources\boot.wim /index:1 /mountdir:C:\winpe_amd64\mount

Note

If this command fails, make sure that you are using the Windows 8.1 version of the DISM tools that is installed together with the Windows ADK and not an older version of DISM.exe from the version of Windows on your technician computer. The Dism /mount-image command is only available in the new version of the DISM tools.
For example, on a Windows 8 computer, you can use the Deployment and Imaging Tools Environment to access the tools that are installed together with the ADK. The Deployment and Imaging Tools Environment adds the new version of DISM into the system path automatically.

  1. Add drivers into the Windows PE base-image file by using the Dism /Add-Driver command. For example, in this step, you add a fictional driver that is named network.inf:

    Dism /image:C:\winpe_amd64\mount /Add-Driver /Driver:C:\Drivers\network.inf
    
  2. Add packages into the Windows PE base-image file by using the Dism /Add-Package command. For example, in this step, you add the Windows RE Configuration optional component and its dependent optional components:

    Dism /Image:C:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WinReCfg.cab"
    
  3. For each component you add, add the corresponding language packs.

    Dism /Image:C:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WinReCfg_en-us.cab"
    
  4. Commit your customizations and unmount the image. To do this, run the following command:

    Dism /unmount-image /mountdir:C:\winpe_amd64\mount /commit
    

1.3 Install Windows PE on a USB flash drive

  1. Connect the USB flash drive.

  2. Type the following command to install Windows PE:

    MakeWinPEMedia /UFD C:\winpe_amd64 F:
    

    where F is the drive letter for the USB flash drive.

1.4 Boot the reference computer to Windows PE

  1. Connect the USB flash drive to the reference computer.

  2. Verify that the computer is configured to boot to a USB device.

  3. Start the reference computer. Windows PE starts automatically. This may take a few minutes.

  4. After the Windows PE command prompt appears, remove the USB flash drive from the reference computer, and then turn off the computer. For example, hold down the power button for more than five seconds.

Troubleshooting

If the reference computer does not boot from the USB flash drive, try the following steps in sequence, and retest between each step:

  1. Turn on the reference computer, and then press the key that opens the boot-device selection menu for the computer, such as the ESC key. Select the USB flash drive as the boot device.

  2. Insert the USB flash drive into a different USB port on the reference computer. Avoid using USB hubs or cables, because they may not be detected during the boot sequence.

  3. If you are using unsigned drivers for testing, disable driver signature enforcement. To do this, follow these steps:

    1. Reboot the reference computer, and then press the Spacebar.

    2. When the Windows Boot Options menu opens, press F8 to open the Advanced Boot Options menu.

    3. Select Disable Driver Signature Enforcement, and then press Enter.

    4. Reboot the computer.

  4. Update the firmware of the reference computer to the latest version.

  5. Try booting Windows PE from a DVD instead. To create a DVD, follow these steps:

    1. Use the following command to create an ISO file that you can burn onto a DVD:

      MakeWinPEMedia /ISO C:\winpe_amd64 c:\winpe_amd64\winpe.iso
      
    2. In Windows Explorer, open the C:\winpe_amd64 folder, right-click winpe.iso, and then select Burn to disc. Follow the prompts to create a DVD.

Step 2: Create and Modify Answer Files

In this section, you create answer files to use together with Windows Setup and the System Preparation (Sysprep) tool. An answer file is an XML-based file that tells Windows Setup how to configure the Windows installation during an unattended installation. In your answer file, you will add basic customizations that every computer in your organization shares.

You can use Windows System Image Manager (Windows SIM) to create and modify answer files. Windows SIM helps you edit settings for the Windows edition that you are installing. To determine which settings are available, Windows SIM creates and reads a catalog file. A catalog file is a small file that summarizes the settings that are available in a specific Windows image.

Note

In this section, you install Windows on a reference computer. You can add any settings that will affect every computer in your organization.

2.1 Create a catalog file

  1. On the technician computer, insert the Windows product DVD into the DVD drive.

  2. On the technician computer, copy the Windows base-image file, \Sources\Install.wim, from the Windows product DVD to the Windows desktop.

  3. Click Start, type image manager, and then select Windows System Image Manager.

  4. On the File menu, click Select Windows Image.

  5. In the Select a Windows Image window, browse to the Windows image file (Install.wim).

Note

If the .wim file contains multiple images, you receive a prompt to select a specific image. Windows SIM creates a catalog file that is based on the image file that you select in the Install.wim file. This process may take several minutes.

The catalog file appears in the **Windows Image** pane. Windows SIM lists the configurable components and packages in that image.

Note

Troubleshooting: If Windows SIM does not create the catalog file, try the following steps:

  • Determine whether you are running the 32-bit or 64-bit version of Windows. The 32-bit version of Windows SIM can create catalog files for both 32-bit and 64-bit versions of Windows. The 64-bit version of Windows SIM can only create catalog files for 64-bit computers.

  • Make sure that the Windows base-image file (Install.wim) is in a folder that has read-write permissions, such as on a USB flash drive or on your hard drive.

2.2 Open a sample answer file

  1. On the File menu, click Open Answer File.

  2. Select a sample Autounattend.xml file, such as Autounattend_ amd64_BIOS _Sample.xml, from the C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools\Samples\Unattend folder. These sample files include all of the settings needed to automate Windows installation.

    Different sample files can be used depending on the hardware type you are deploying Windows to (32-bit ad 64-bit installations, as well as EFI or BIOS-based firmware).

    The answer file appears in the Answer File pane. Windows SIM lists the settings that have already been added to that file.

2.3 Add drivers and packages to your answer file (Optional)

  • To add a driver, click Insert, select Driver Path, and select pass 1 windowsPE. The WindowsPE configuration pass is used in initial installation, which is ideal for boot-critical drivers.

  • To add a package, click Insert, select Package, and then browse to the package that you want to add.

2.4 Create an answer file to customize Windows

  1. In this step, you customize a sample answer file by adding your own settings. The sample answer file already includes default disk partition information and basic Windows customizations. You can add more customizations to this sample answer file. To do this, modify the following setting:
Answer File Component Path Configuration Pass Setting and Value

Microsoft-Windows-Setup\UserData\ProductKey

1 windowsPE

Key=Product Key

The product key you use must match the product key for the Windows edition that you want to install.

  1. Remove the following setting from the answer file. To do this, right-click the component in the Answer File pane, and then select Delete:

    • 4_specialize\Microsoft-Windows-Shell-Setup\OEMInformation
  2. Add more settings to your answer file. These examples demonstrate how to configure the Internet Explorer home page and how to boot Windows to audit mode. Audit mode is used to configure the Windows installation and to run more applications.

Windows Image Component Path Configuration Pass Setting and Value

Microsoft-Windows-IE-InternetExplorer

1 windowsPE

Home_Page=URL

where URL is the default home page you want to open when users run Internet Explorer.

Microsoft-Windows-Deployment\Reseal

7 oobeSystem

ForceShutdownNow=false

Mode=Audit

  1. You can use the following components to configure Windows more during installation. Review and add any of the following settings to your answer file from the Windows Image pane.
Option Windows Image Component Path

Configure TCPIP Networking

Microsoft-Windows-TCPIP

Configure Windows Firewall

Networking-MPSSVC-Svc

Configure local accounts and domain accounts

Microsoft-Windows-Shell-Setup\UserAccounts

Automatically join a domain

Microsoft-Windows-UnattendedJoin

Automatically log on to the computer by using a specific account

Microsoft-Windows-Shell-Setup\AutoLogon

Automatically run a script when a user logs on to the computer

Microsoft-Windows-Shell-Setup\FirstLogonCommands

  1. Add any other settings that will be common to all of the computers in your organization. For more information about available answer file settings, see Unattended Windows Setup Reference Guide.

  2. Remove the USB flash drive from the reference computer, and then connect it to the technician computer.

  3. In Windows SIM, click Tools, and then click Create Configuration Set. A configuration set includes an answer file (AutoUnattend.xml) and any related drivers, packages, and other files.

  4. In the Select the target folder for the configuration set box, type the drive letter of the USB flash drive, such as F.

2.5 Create an answer file to customize the default user profile

  1. Create a second answer file to use when you run Sysprep to generalize the Windows installation. This answer file contains the CopyProfile setting and is used to copy the customizations that you make in audit mode to the default user profile.

    In Windows SIM, create a new answer file. To do this, click File, and then click New Answer File.

  2. Add the following setting to your answer file:

Windows Image Component Path Configuration Pass Setting and Value

Microsoft-Windows-Shell-Setup

4 specialize

CopyProfile=True

  1. Save the answer file as CopyProfileunattend.xml on the USB flash drive.

Step 3: Use the Answer File to Install Windows

In this section, you install Windows on the reference computer by using the answer files that you created.

These steps also demonstrate how to customize Windows by using audit mode. In audit mode, you can log on to Windows by using the built-in administrator account and manually perform tests and tasks that can be difficult or impossible during installation.

3.1 Install Windows on the reference computer

Start Windows Setup by using one of the following methods:

  • Option 1: Start Windows Setup by using the Windows product DVD.

    This is the simplest method to install Windows on most computers.

  • Option 2: Start Windows Setup by using Windows PE.

    Use this option to load Windows onto a system that does not have a DVD drive, or if option 1 is not successful.

Option 1: Start Windows Setup by using the Windows product DVD

  1. On the reference computer, insert the Windows product DVD, and then connect the USB flash drive that includes the answer file to the computer.

  2. Boot the computer. If you receive a prompt, press a key to boot from the DVD.

    Windows Setup starts. This process might take a few minutes.

Note

Troubleshooting: If Windows Setup does not start, or does not automatically complete the Setup process, try the following steps. If one step does not solve the problem, continue to the next step:

  1. Restart the reference computer. During the initial boot sequence, press the key that opens the boot-device selection menu for the computer, such as ESC. Select the DVD drive as the boot device.

  2. Make sure that the answer file is in the root directory of the USB flash drive, and is named Autounattend.xml.

  3. Try using a different USB port on the computer. Avoid USB hubs or cables, because they may not be detected during the boot process.

  4. Use option 2 to start Windows Setup by using Windows PE.

Option 2: Start Windows Setup by using Windows PE

  1. On the technician computer, copy the contents of the Windows DVD to the USB flash drive. For example, run the following command:

    Robocopy D:\ F:\WindowsSetup\ /e
    

    where D is the drive letter of the DVD drive and F is the drive letter of the USB flash drive.

  2. Remove the USB flash drive from the technician computer, and then connect the USB flash drive to the reference computer.

  3. Start the reference computer. The computer boots Windows PE. This process can take a few minutes.

Note

Troubleshooting: If Windows PE does not start, try the following steps. If one step does not solve the problem, continue to the next step:

  • Restart the reference computer. During the initial boot sequence, press the key that opens the boot-device selection menu for the computer, such as ESC. Select the USB flash drive as the boot device.

  1. Run the following command:

    F:\WindowsSetup\setup /unattend:F:\autounattend.xml
    

    where F is the drive letter of the USB flash drive.

    Windows Setup starts. The installation process can take a few minutes.

3.2 Customize the default user profile

  1. You can make more customizations in audit mode. For example, you can add shortcuts on the desktop to a VPN client, a specific website, or other resources. You can also change the desktop background to an image of your company’s logo. Note that items that are pinned to the taskbar or to the Start screen are not copied to the default user profile.

    Insert the USB flash drive that contains the CopyProfileunattend.xml answer file in the reference computer.

  2. Copy any scripts or files and install any applications on the Windows installation that you want to make available in all your Windows installations. For example, you can install your own software management tools or IT support scripts.

  3. Customize the default user profile by creating one or more shortcuts on the desktop. For example, you can create a shortcut to network resources by creating a URL shortcut or a UNC path shortcut.

  4. Change the desktop background image to your company logo.

Step 4: Capture the Image

In this section, you prepare the Windows installation on the reference computer so that you can capture the installation as an image file.

Generalizing the reference computer prepares the files for image capture by removing computer-specific information.

4.1 Generalize the Windows installation

  1. After you have completed customizing the Windows installation, you are ready to capture the image and copy the customizations that you made to the default user profile.

    Verify that the USB flash drive that contains the CopyProfile.xml file is inserted into the computer.

    Run the following command as an administrator:

    C:\Windows\System32\Sysprep\Sysprep.exe /generalize /oobe /shutdown /unattend: D:\CopyProfile.xml
    

    where D is the drive letter of the USB flash drive.

    Sysprep removes computer-specific information from the Windows installation so that you can capture an image that you can deploy to other computers. This process can take several minutes. After the process finishes, the computer shuts down automatically.

Warning

Do not allow the reference computer to start its first boot sequence. If the computer starts its first boot sequence, Windows Setup adds the computer-specific information back to the computer. You must then remove this information by generalizing the computer again before you can capture the image.

4.2 Capture the image

  1. Connect the USB flash drive to the reference computer, and then boot Windows PE.

Warning

Troubleshooting: If Windows PE does not start, shut down the reference computer quickly by pressing and holding the power button.
Try the following steps to boot Windows PE. If one step does not solve the problem, continue to the next step:

  1. Restart the reference computer. During the initial boot sequence, press the key that opens the boot-device selection menu for the computer, such as ESC. Select the USB flash drive as the boot device.

  2. If the USB flash drive has an indicator light, watch to see whether the light flickers. If the light flickers, the computer is booting to Windows PE.

  3. Try using a different USB port on the computer. Avoid USB hubs or cables, because they may not be detected during the boot process.

  1. At the Windows PE command prompt, run the following command:

    diskpart
    
  2. At the Diskpart prompt, type list volume. DiskPart lists the available disk partitions and their sizes.

  3. Write down the drive letters and names, such as the following:

    • C = System

    • D = Windows

    • E = External USB hard disk drive

    • F = USB flash drive

  4. Type exit to leave DiskPart.

  5. Run the following command to capture the image of the Windows partition:

    dism /Capture-Image /CaptureDir:D:\ /ImageFile: E:\ThinImage.wim /Name:"Contoso"
    

    where D is the drive letter for the Windows partition and E is the drive letter for the external USB hard disk drive.

    The DISM tool captures the Windows partition in a new image file. This process can take several minutes.

Note

Although you can capture the image directly to the external USB hard disk drive, the faster method is usually to capture the image onto a hard disk drive, and later copy the image file to the USB flash drive.

  1. Connect the external USB hard disk drive to the computer, create an Images folder, and then copy the image file to the drive. To do this, run the following command:

    md E:\Images
    copy D:\ThinImage.wim E:\Images\
    

    where E is the drive letter for the external USB hard disk drive, and D is the drive letter for the Windows partition.

    This process can take several minutes, because the image file is several gigabytes in size.

Note

Troubleshooting: If you receive an "A parameter is incorrect" error message when you copy the file, the file may be too large for the destination file system. Try copying the file to a disk that is formatted as NTFS.

  1. Turn off the computer.

Step 5: Deploy Windows to Test Computers

In this section, you create deployment scripts that apply the image to the test computer and set up full-system recovery tools.

You create the following scripts:

  • The DiskPart script, named CreatePartitions.txt, formats the hard disk drive and creates partitions based on the firmware of the computer.

  • A deployment script, named ApplyImage.bat, configures a computer by using the Windows image file that you captured in Step 4: Capture the Image. To configure the computer, the deployment script uses the DiskPart script, and then automatically configures the system partition.

5.1 Create a DiskPart script

  1. Connect the external USB hard disk drive to the technician computer.

  2. For UEFI-based computers: Start Notepad and create a text file that includes commands to create the following five partitions:

    • Windows RE Tools

    • System

    • Windows

    • Microsoft Reserved (MSR)

    • Recovery image

    The following diagram shows the resulting partition configuration:

    rem == CreatePartitions-UEFI.txt ==
    rem == These commands are used with DiskPart to
    rem    set up the drive and ecreate five partitions
    rem    for a UEFI/GPT-based computer.
    rem    Adjust the partition sizes to fill the drive
    rem    as necessary. ==
    select disk 0
    clean
    convert gpt
    rem == 1. Windows RE tools partition ===============
    create partition primary size=300
    format quick fs=ntfs label="Windows RE tools"
    assign letter="T"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    gpt attributes=0x8000000000000001
    rem == 2. System partition =========================
    create partition efi size=100
    rem ** NOTE: For Advanced Format 4Kn drives,
    rem          change this value to size = 260 **
    format quick fs=fat32 label="System"
    assign letter="S"
    rem == 3. Microsoft Reserved (MSR) partition =======
    create partition msr size=128
    rem == 4. Windows partition ========================
    rem ==    a. Create the Windows partition ==========
    create partition primary 
    rem ==    b. Create space for the recovery image ===
    shrink minimum=15000
    rem ==    c. Prepare the Windows partition ========= 
    format quick fs=ntfs label="Windows"
    assign letter="W"
    rem === 5. Recovery image partition ================
    create partition primary
    format quick fs=ntfs label="Recovery image"
    assign letter="R"
    set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac"
    gpt attributes=0x8000000000000001
    list volume
    exit
    
  3. For BIOS-based computers: Start Notepad and create a text file that includes commands to create the following three partitions:

    • System

    • Windows

    • Recovery image

    The following diagram shows the resulting partition configuration:

    rem == CreatePartitions-BIOS.txt ==
    rem == These commands are used with DiskPart to
    rem    set up the drive and create three partitions
    rem    for a BIOS/MBR-based computer.
    rem    Adjust the partition sizes to fill the drive
    rem    as necessary. ==
    select disk 0
    clean
    rem == 1. System partition ======================
    create partition primary size=350
    format quick fs=ntfs label="System"
    assign letter="S"
    active
    rem == 2. Windows partition =====================
    rem ==    a. Create the Windows partition =======
    create partition primary
    rem ==    b. Create space for the recovery image  
    shrink minimum=15000
    rem ==    c. Prepare the Windows partition ====== 
    format quick fs=ntfs label="Windows"
    assign letter="W"
    rem == 3. Recovery image partition ==============
    create partition primary
    format quick fs=ntfs label="Recovery image"
    assign letter="R" 
    set id=27
    list volume
    exit
    
  4. Save the file as E:\CreatePartitions.txt, where E is the drive letter for the external USB hard disk drive.

5.2 Create the deployment script

  1. UEFI-based computers: Create a text file that performs the following tasks:

    • Uses the DiskPart script (from section 5.1) to erase the primary hard disk drive, and then to create and format five partitions.

    • Copies the image into the Recovery Image partition.

    • Applies the image to the Windows partition.

    • Copies the Windows RE tools from the Windows partition to the Windows RE tools partition.

    • Copies boot files from the Windows partition to the System partition.

    • Configures the System partition by setting the locations of the Windows partition and the recovery tools.

    rem == ApplyImage-UEFI.bat ==
    
    rem == These commands deploy a specified Windows
    rem    image file to the Windows partition, and configure
    rem    the system partition.
    
    rem    Usage:   ApplyImage WimFileName 
    rem    Example: ApplyImage E:\Images\ThinImage.wim ==
    
    rem == Copy the image to the recovery partition ==
    md R:\RecoveryImage
    copy %1 R:\RecoveryImage\Install.wim
    
    rem == Apply the image to the Windows partition ==
    dism /Apply-Image /ImageFile:"R:\RecoveryImage\Install.wim" /Index:1 /ApplyDir:W:\
    
    rem == Copy boot files to the System partition ==
    W:\Windows\System32\bcdboot W:\Windows
    
    :rem == Copy the Windows RE image to the
    :rem    Windows RE Tools partition ==
    md T:\Recovery\WindowsRE
    xcopy /h W:\Windows\System32\Recovery\Winre.wim T:\Recovery\WindowsRE\
    
    :rem == Register the location of the recovery tools ==
    W:\Windows\System32\Reagentc /Setreimage /Path T:\Recovery\WindowsRE /Target W:\Windows
    
    :rem == Register the location of the push-button reset recovery image. ===
    W:\Windows\System32\Reagentc /Setosimage /Path R:\RecoveryImage /Target W:\Windows /Index 1
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  2. BIOS-based computers: Create a text file that performs the following tasks:

    • Uses the DiskPart script (from section 5.1) to erase the primary hard disk drive, and then to create and format three partitions.

    • Copies the image into the Recovery Image partition.

    • Applies the image to the Windows partition.

    • Copies the Windows RE tools from the Windows partition to the System partition.

    • Copies boot files from the Windows partition to the System partition.

    • Configures the System partition by setting the locations of the Windows partition and recovery tools.

    rem == ApplyImage-BIOS.bat ==
    
    rem == These commands deploy a specified Windows
    rem    image file to the Windows partition, and configure
    rem    the system partition.
    
    rem    Usage:   ApplyImage WimFileName 
    rem    Example: ApplyImage E:\Images\ThinImage.wim ==
    
    rem == Copy the image to the recovery partition ==
    md R:\RecoveryImage
    copy %1 R:\RecoveryImage\Install.wim
    
    rem == Apply the image to the Windows partition ==
    dism /Apply-Image /ImageFile:"R:\RecoveryImage\Install.wim" /Index:1 /ApplyDir:W:\
    
    rem == Copy boot files to the System partition ==
    W:\Windows\System32\bcdboot W:\Windows
    
    :rem == Copy the Windows RE image to the System partition ==
    md S:\Recovery\WindowsRE
    xcopy /h W:\Windows\System32\Recovery\Winre.wim S:\Recovery\WindowsRE\
    
    :rem == Register the location of the recovery tools ==
    W:\Windows\System32\Reagentc /Setreimage /Path S:\Recovery\WindowsRE /Target W:\Windows
    
    :rem == Register the location of the push-button reset recovery image. ===
    W:\Windows\System32\Reagentc /Setosimage /Path R:\RecoveryImage /Target W:\Windows /Index 1
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  3. Save the file as E:\ApplyImage.bat, where E is the drive letter for the external USB hard disk drive.

5.3 Run the diskpart script on the test computer

  1. Boot Windows PE. To do this, follow these steps:

    1. On the test computer, insert the USB flash drive that contains Windows PE.

    2. Start the test computer, and then press a key to open the boot device selection menu for the test computer.

    3. Select the USB flash drive as the boot device.

      Windows PE starts automatically. This process can take a few minutes.

  2. At the Windows PE command line, run the following command:

    diskpart /s E:\CreatePartitions.txt
    

    where E is the drive letter of the external USB hard disk drive.

    The scripts create and configure the partitions on the test computer.

  3. Verify that the script was successful. To do this, follow these steps:

    1. Type diskpart.

      The diskpart prompt appears.

    2. At the diskpart prompt, type list volume.

      Diskpart shows the partitions, such as E = External USB hard disk drive; F = USB flash drive; R = Recovery image; S = System; T = Windows RE Tools; W = Windows. The MSR partition will not have a drive letter.

    3. Type exit to return to the Windows PE command prompt.

5.4 Run the deployment script on the test computer

  1. At the Windows PE command prompt, run the following command:

    E:\ApplyImage E:\Images\ThinImage.wim
    

    where E is the drive letter for the external USB hard disk drive.

    This step may take several minutes.

  2. Disconnect the external USB hard disk drive from the test computer, and then type exit.

5.5 Verify the Windows installation on the test computer

  1. Restart the test computer. Windows Welcome starts.

  2. During Windows Welcome, create a local user account.

  3. Verify that your customizations appear and that the hard disks and recovery images exist.

    If your customizations, the hard disk partitions, and the recovery files appear, you have a customized Windows image and simple deployment scripts that you can use together with the computer in your organization.