Applying a Windows 7 .WIM Image Using ImageX

In my WinPE-related posts I have written a few how-to posts on building a Windows PE boot disk, capturing a Windows 7 image and adding drivers to a .wim image offline. This leads me nicely onto this post about applying Windows 7 .WIM images using the ImageX tool.

What you will need

  • Windows PE boot disk with ImageX
  • .WIM Windows 7 image file
  • Target computer to apply the Windows 7 image

Instructions

1) Boot your target computer with the Windows PE boot disk

You will need a Windows PE boot disk with access to the ImageX tool.  Check out my previous post on how to create Windows PE USB boot disk.

2) Partition the Hard Disk

The first step here is to create two partition on the target disk –one for the System partition and the other for the actual Windows installation. The “System” partition is reserved for the BCD store (for booting), the Windows Recovery Environment and BitLocker for some Windows 7 editions.

OK, so proceed with these instructions on the Windows PE command prompt, adapting it to your needs as necessary (you may want another partition for your data, for example). Here, though we’re only creating the default System and Windows partitions:

diskpart
select disk 0
clean
create partition primary size=300
format quick fs=ntfs label="System"
assign letter=S 
active 


create partition primary
format quick fs=ntfs label="Windows"
assign letter=W
exit

We are assigning the Windows partition the drive letter W only to avoid potential drive letter conflicts. You will notice that the Windows partition will revert to drive C:\ when you launch Windows. Also you will not see the System partition as this is typically hidden from view.

3) Prepare the source where the .WIM image file is located

3.1) Image is located on a local drive

If your .WIM image is stored on a local drive such as a USB hard disk then you need to identify the drive letter of the drive. Use diskpart as below to work this out

diskpart
list volume

This will present a table of all drives attached to your computer and the drive letter associated with it

3.2) image is located on a network share

If on the other hand your .WIM image is on a network share then use the net use command to map the share to a drive letter as below

net use N: \\ServerName\ShareName * /user:username

In the above example the drive letter we’re mapping to our share is N. Use your own network share and a user account and enter the password when prompted for the user account.

4) Apply the Image

Here’s the basic format of the imagex capture command:

Imagex /apply wim-image index destination-drive

And here’s an example where our .WIM image is located in D:\Images\ref-win7-image.wim and the destination drive is W:\

imagex /apply D:\Images\ref-win7-image.wim 1 W:\

You should see the progress of the image being applied in percentages, followed by a

“Successfully applied image” message once the image has been applied.

5) Configure BCD boot

After the image has finished being applied to the destination drive we now use bcdboot.exe to copy the default boot files from our Windows partition to the ‘System’ partition.

The example below copies the boot files to the S:\ drive (which is the drive letter we associated with the System partition in Step 2)

W:\windows\system32\bcdboot.exe w:\windows /s S:\

Once you run the command you should see a confirmation message such as “Boot files successfully created”.

This final step completes the whole process of using ImageX to apply a Windows 7 image to a destination drive.

Summary

  • Boot computer with Windows PE, and use diskpart to create a System partition and a Windows partition
  • Prepare the source directory where the .WIM image is located – use diskpart to work out the drive letter of a local disk where the image is stored or if the image is stored on a network share use the net use command to map a network share to a drive letter
  • Use the imagex /apply command to apply the.WIM image form the source directory to the Windows partition created earlier
  • And finally use bcdboot.exe to copy boot files to the System partition

Follow Me, Myself and IT on Twitter:

Advertisements

18 thoughts on “Applying a Windows 7 .WIM Image Using ImageX

  1. Just used it again (keep forgetting commands) and still works perfectly … I probably had more of an issue just trying to get a WinPE cd with imagex to boot than deploying here. Tried a few other examples and yours goes through everything you need to do to deploy correctly. Just thought I would say thanks again :)

  2. Great write up!

    I’m having issues with step 5 however. I apply the image to W:\ and try to copy the boot files to S:\ with “bfsvc error: failed to create system store” or “bfsvc error: failed to copy boot files” (something along those lines) any ideas what could be causing the errors?

    • I’ve had this same issue a couple times, just reboot back into the WinPE environment and try again, normally works after a reboot (not sure why but I had that issue a couple times).

      Whenever you get to command prompt you can switch to the different drives ( try C: D: E: F: ) and if you run “dir” it should show the label, you’re looking for the one with System which would be where you want to install the boot files (which was S in this tutorial).

      You can also go back into diskpart and then use “list disk” “list partition” to get better idea of which disk is the right one (if you have multiple disks installed)

  3. This version of W:\windows\system32\bcdboot.exe is not compatible with the version of windows you’re running. I am deploying 64 bit windows, do I need winPE in 64 bit also?

  4. Awesome article couple of problems arose however you forgot to mention a 2nd computer at the side as a pre-requisite with some good tunes and try to get your solitaire average up while you wait for the
    “apply” certainly a whole lot quicker than a full reinstall and packing all your stuff back in and good for space too. The whole image, drivers, office and a couple of app’s came to a whopping 4.7GB and way quicker than waiting for windows update to do its thing and doing a full bare metal reinstall. Keep up the good work thx a bunch once again :)

  5. 3.2) image is located on a network share

    If on the other hand your .WIM image is on a network share then use the net use command to map the share to a drive letter as below

    net use N: \\ServerName\ShareName * /user:username

    In the above example the drive letter we’re mapping to our share is N. Use your own network share and a user account and enter the password when prompted for the user account.

    Hello, Am unable to configure the above path with server name / share name. Can you pls guide me whether the Server name can be any Desktop PC where i can store the image( which i already tried). I couldnt able to connect to that desktop.

    • The WIM image can be on a desktop PC, no problem. Just use \\computername\sharename format. Also make sure the user account you use to mount the share has security and share permissions to access it.

      You can also substitute the computer name with the IP address of the PC – e.g. \\192.168.0.100\ShareName

      • Thanks for your reply, We have a embedded PC (VPB) its a industrial PC. We have image in .wim format for which we are trying to restore the image, but unfortunately after booting the Industrial PC with the Winpe bootable USB, we are unable to restore the image through \\Servername\share . It asks for Username and Password, but still shows context is invalid after entering the same. i have shared the folder with security permission.
        Can you let me know what will be the default IP address of the PC we boot with WinPE bootable USB.

        Please can you share me if u have any step by step procedure if you have to santu.sri@gmail.com.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s