Friday, May 3, 2013

How to capture and apply an image with WinPE 4 and Windows ADK.

How To Capture and Apply an Image With WinPE 4 and Windows ADK

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

WinPE4 & DISM make this sooo 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 infact.)

Guide to WinPE USB Creation: TechNet WinPE USB Drive Creation

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:


  • An OS that has already been Sysprepped/Unattend prepared!
  • 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.)
  • External Drive (or another Internal Drive for storing the image to be ripped.)

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, as well as assigning easily rememberable drive letters.


diskpart 
list disk 
select disk 0 // or which disk has your Windows pre-capture 
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 recognizable  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 to the external drive:
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:

The following will completely erase all information on said drive so be careful, or take additional steps to customize it per your system.

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.

Important note:  If you are unable to boot into your OS, when everything is said and done, you probably forgot the Active command.  This marks the partition as an active and valid system partition both inside the WinPE but also outside (boot time).  Meaning, if you failed to mark it active, this is 99% of the reason there is No Boot Media message or Boot Manager is Missing.  Don't fret, simply redo the whole process, and properly apply BCDBOOT afterward applying the image.

Whatever drive the Ext HDD is (L:\ for example), navigate to the DISM folder.
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 we made it active after partitioning.  (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




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.

2 comments:

  1. Thanks dude, this is very concise and extremely helpful!

    ReplyDelete
    Replies
    1. Sorry for the late response, I have been on hiatus! I am glad you liked it!

      Delete