Reaper's Edge‎ > ‎

WinPE + Gimagex = Your core imaging tool

posted Sep 25, 2010, 3:51 PM by Michael Wilson   [ updated Sep 26, 2010, 8:52 AM ]
To be able to capture an image you need to be able to access the hard drive offline and make a copy of it. The best way I've found to do that is to use Gimagex from within WinPE. Unfortunately you can't just download this tool and will have to assemble it. The good news is that all the parts are free and I'm here to help you.

Step 1: Download and install the Windows AIK
    You can download it here or just do a search for WAIK and Windows 7. You can only install this on Windows 7 or Vista SP1, but if that's a problem there's an older version you can download that should work just as well. The download comes in the form of an ISO file containing the software. Lame, I know, but either burn it to DVD or just mount the ISO with something like Daemon Tools and get to installing.

Step 2: Create a WinPE image.
    Now it starts getting a little more complicated, and I'm afraid the command prompt is involved, sorry.
    1. WAIK should have installed a shortcut to an item called the Deployment Tools Command Prompt. You'll need to open this with admin privileges.

    2. From this command prompt run the following commands in order
        copype.cmd x86 c:\winpe_x86        (Note that the x86 is for WinPE itself and will still allow to capture both x86 and x64 PC images.)
        copy c:\winpe_x86\winpe.wim c:\winpe_x86\iso\sources\boot.wim
        
    3. Open Notepad and create a file called wimscript.ini and include the following text:
[ExclusionList]
\temp

    4. Save a copy of wimscript.ini to c:\winpe_x86\iso

    5. Go back to the Deployment Tools Command Prompt and run the following command
        oscdimg -n -bC:\winpe_x86\etfsboot.com c:\winpe_x86\iso C:\winpe_x86\winpe_x86.iso

    At this point you've created a functioning WinPE image, but it doesn't contain any tools yet.

Step 3: Burn or Mount the winpe_x86.iso and copy all of the contents to a new folder
    The iso is irrelevant at this point, we just need the contents.
    For this example lets say we copied the contents of the ISO to the folder c:\Image

Step 4: Download the gimagex tool here. This is the famed ImageX tool, wrapped in a functional GUI shell. Make two copies of the tool in two different folders, because we're going to run it and copy it at the same time coming up.

Step 5: Mount the boot.wim file and insert tools into it.
    1. Create an empty folder, for this example I'll use c:\wimmount
    2. Run one of the copies of Gimagex (it will only run as an admin, fyi)
    3. Go to the Mount tab and set the following:
        Mount Point = c:\wimmount
        Source = c:\image\sources\boot.wim
        Image = 1
        Check Read and Write
        Click Mount
    4. Once the mount completes successfully navigate to c:\wimmount and notice it contains a mini Windows install.
        Navigate to the folder c:\wimmount\windows\system32
        This is where we are going to dump all of our tools and customizations

Step 6: Prepare our contents for the WinPE image.
    There are only a few things we truly need at this point, but there are several that will make our lives tremendously easier down the road.
    Create the following files and tuck them away for later
        startnet.bat
        formatbat.cmd
        nuke.cmd
        off.cmd
        delpart.txt
    Below you'll find each of the files attached and saved as text files. You'll want the contents of the files to match, though feel free to tinker.

Step 7: Copy all of our stuff into the WinPE Image 
    Return to the folder c:\wimmount\windows\system32 and copy in all of the following, overwriting existing files where necessary:
        startnet.bat
        formatbat.cmd
        nuke.cmd
        off.cmd
        delpart.txt        
        gimagex.exe
        imagex.exe - from the folder "c:\program files\windows AIK\tools\x86\"
    Once you have all the files copied close all open windows that point to c:\wimmount directory or any subdirectories. Miss this step and it will corrupt your image. That's bad.

Step 8: Save changes to the WinPE image.
    Go back to the Giamgex program you opened in step 5
    On the Mount tab, highlight the image you're working on, check the box Commit Changes, and click Unmount
    At this point we have an awesomely automated WinPE image, now we need to put it somewhere. In this example I'll show you how to use it to make a bootable WinPE USB drive

Step 9: Prep the USB drive
    The size of the drive is up to you, but should be based on whether you intend to store PC images on the USB drive along with WinPE. If not, you only need a 256MB stick. If you will carry images on it I recommend at least an 8GB and preferably 16GB, the faster the better.
    To prep the USB drive, insert it into the PC and open an elevated command prompt, then run the following commands:
        diskpart
        list disk    (Take note of which disk number is your USB drive. You don't want to accidentally wipe the wrong drive, right?)
        select disk n    (Where n is the disk number for the USB drive.)
        clean
        create partition primary
        format fs=ntfs
        assign
        active
        exit

Step 10: Copy WinPE to the USB drive
    Copy all of the contents of the folder c:\image to the USB drive

That is it, you are done.

To use, simply plug the drive into a PC and boot to it. It will take you to command prompt with some well written text explaining what the valuable commands are, including how to launch the GUI tool Gimagex.

A couple more closing thoughts; this USB stick can be used to both capture drive images, and to apply drive images. Also, with a little bit of modification to the text of formatbat.cmd you can create an automated drive that will ask the user to pick a number, and based on that number, image the drive using one of several images. Incidentally, it makes use of the imagex tool I had you include earlier, just in case. Here's a sample text to help you a long if you're interested:
REM This file will wipe the hard drive and install a wim image
REM Written by Michael Wilson on 5/20/2010

@echo off
echo "Input number to select image type:"
echo "1 - Staff XP from 5/18/2010"
echo "2 - Public XP from 4/29/2010"
SET /P ImageNum=[promptString]

if "%ImageNum%"=="1" diskpart /s delpart.txt
if "%ImageNum%"=="1" imagex /apply e:\combinedxp.wim 1 c:
if "%ImageNum%"=="2" diskpart /s delpart.txt
if "%ImageNum%"=="2" imagex /apply e:\combinedxp.wim 2 c:

wpeutil shutdown

Enjoy.
ċ
delpart.txt
(0k)
Michael Wilson,
Sep 25, 2010, 4:54 PM
ċ
formatbat.txt
(0k)
Michael Wilson,
Sep 25, 2010, 4:54 PM
ċ
nuke.txt
(0k)
Michael Wilson,
Sep 25, 2010, 4:54 PM
ċ
off.txt
(0k)
Michael Wilson,
Sep 25, 2010, 4:54 PM
ċ
startnet.txt
(0k)
Michael Wilson,
Sep 25, 2010, 4:54 PM
Comments