Rip A Windows 7/8 Image That's Been Sysprepped Using WinPE4.0 And DISM

An article I wrote a while back at Overclock.Net. I am not sure if it's any good anymore, but have at it!

To begin with, you need downloaded and installed: Windows ADK.

WinPE4 & DISM make this so much easier now, and support such a large variety of machines out of the box that it made me less Raging for the first time in a very long time. No need for 3rd party tools or guides (unless you get extremely fancy), straight from Microsoft (all of this material is straight from MS in fact.)

Guide to WinPE USB Creation: http://technet.microsoft.com/en-us/library/hh825109.aspx

Once ADK is also installed, you will want those deployment tools from its folder on the External.

They are found here:
C:\Program Files (x86)\Windows Kits\8.0\Assessment and Deployment Kit\Deployment Tools

Copy the Deployment Tools folder to your external drive and name it something you will remember, since this is the core of WADK tools, I named my copied folder WADK.

Recommended Tools Before Beginning
  1. An OS that has already been Sysprepped/Unattended prepared!
  2. 2~4GB Flash Drive (Since it is usually FAT32, you don’t want to store your 4GB+ file sized image here so just use it for booting PE4.)
  3. External Drive (or another Internal Drive for storing the image to be ripped.)


Beginning!

Boot to the USB WinPE4.0 after your OS has been sysprepped. If you have successfully created a bootable flash drive via the first guide, you should be sitting at a pretty CMD in fast and sexy WinPE4.0. This should be the default directory you are looking at after it is finished loading:

X:\Windows\System32
From here, we need to see what WinPE has done about labeling your drives and partitions.
diskpart
select disk 0
list partition
select partition 0 //only if you use a system partition
assign letter="S" //S for System
select partition 1 //again, would be 0 if there is no partition ahead of this
assign letter="W" //W for Windows
list volume // Look for you external HDD and remember the Drive letter assigned or change it yourself
exit
Now that we have labeled your drives something recognizeable, we then navigate to the WADK folder on your external drive, using the drive letter you just looked up. Mine was assigned to L. Change root:
L:
Navigate to DISM folder inside of the WADK copy you made:
L:\WADK\AMD64\DISM\


Capturing the Image!

Since your OS is already sysprepped and ready to go, you simply capture the correct partition / drive mount
Dism /Capture-Image /ImageFile:L:\WinImg.wim /CaptureDir:W:\ /Name:"Windows"
Alternatively using UNC and Domain:
net use Z: \\ServerName\SharedFolder /user:domain\user PASSWORD
Dism /Capture-Image /ImageFile:Z:\MyImages\WinImg.wim /CaptureDir:W:\ /Name:"Windows"


Applying a Captured Image

Disk Preparation
diskpart
select disk 0
clean
create partition primary size=100
format quick fs=ntfs label="System"
assign letter="S"
active
create partition primary
format quick fs=ntfs label="Windows"
assign letter="W"
exit
S:\ Is the 100mb system partition which stores boot info.
W:\ Is the Windows partition.
Whatever drive the Ext HDD is (L:\ for example), navigate to the DISM folder.
L:
cd L:\WADK\AMD64\DISM

L:
cd L:\WADK\AMD64\DISM

(If you need to find out what drive letter the external hard drive is use DISKPART followed by the “List Volume” command, the “L:” is just the standard way of changing the root drive letter you are working for. You don’t CD L: or CD Q: to change drives, you simply type the drive letter with a colon.)



Apply Windows Image

dism /apply-image /imagefile:L:\WinImg.wim /index:1 /ApplyDir:W:\
L:\Directory to Image\ImageFile.WIM, the above Images were just stored on the root of the drive.
Upon fully imaging the drive, you want to create correct boot drive options.

Return to RAM DISK X:\ by typing:
X:
Should return you to X:\Windows\System32. If not navigate there with CD. Then run BCDBOOT as such:
bcdboot W:\Windows /l en-US

It will automatically apply to S:\ because of the label. (If it fails for whatever reason you may force application to S drive by using /S S: ) After this it should be good to go and boot the OS.

Sources of Information & Other seriously useful DISM links:
What is Sysprep?
Capturing images with DISM
Applying images with DISM
BCBOOT Command Line Options
Mounting an image and editing files inside it

Note all of this use to be done with a combination of DISM before and ImageX. ImageX is officially deprecated and DISM now retains all functionality and more.