Deployment Image Servicing and Management (DISM) – WinPE 3.0 Boot Environment

I recently compiled a new library of commands since the upgrade from WinPE 2.0 to WinPE 3.0. With Windows 7 coming along they released a new way to create bootable USB sticks using Deployment Image Servicing and Management (DISM.exe). You might be asking yourself, what could I use this for? We are using it at my work to re-image computers, capture backup images, mount images, etc. There are many other uses for it but I will not get into that here. I have literally done this procedure a couple hundred times. In a future article I will show you how to write a simple batch script to automate this process. But it helps to understand what is going on with each command in case you have trouble. Batch scripts never work 100% of the time.

You will need the following to proceed:
Windows® Automated Installation Kit (AIK) for Windows® 7 RC (Download from Microsoft) : 05.01.09

  • Windows® Automated Installation Kit (AIK) for Windows® 7 RC (Download from Microsoft) : 08.06.09
  • Bootable Flash drive (500MB or larger)
  • Once you have installed WAIK then you will need to browse to your start menu and click on “Deployment Tools Command Prompt”. I have provided a picture below.

    DISM

    DISM

    Once you have launched DTCP you will need to follow through the commands I have compiled below. The first one I have provided a screenshot.

    DISM – Step #1 – Prep/Cleanup

    DISM /Cleanup-Wim

    The DISM cleanup command simply cleans up any previous wims/mounts you have been working with. If you do this a lot, you will need to use this command otherwise you will start receiving errors from previous wims possibly still left on the system.

    DISM Step #1

    DISM Step #1

    DISM – Step #2 – Copy WinPE 3.0 to your local C Drive

    copype.cmd x86 c:winpe_x86
    copy c:winpe_x86winpe.wim c:winpe_x86ISOsourcesboot.wim

    This creates a winpe_x86 folder on your C: drive and then copies the contents of the WinPE folder from the WAIK installation to your folder.

    DISM – Step #3 – Mounting .Wim File on your local C Drive

    Dism /Mount-Wim /WimFile:C:winpe_x86winpe.wim /index:1 /MountDir:C:winpe_x86mount

    This command mounts the wim file that was copied over in step #2 so that you can browse the system32 folder and insert your custom scripts, etc.

    DISM – Step #4 – Adding Packages to your WIM

    Dism /image:C:winpe_x86mount /Add-Package /PackagePath:”C:Program FilesWindows AIKToolsPEToolsx86WinPE_FPswinpe-wmi.cab”
    Dism /image:C:winpe_x86mount /Add-Package /PackagePath:”C:Program FilesWindows AIKToolsPEToolsx86WinPE_FPsen-uswinpe-wmi_en-us.cab”

    There are many packages you can add to your WINPE boot environment, these are two I always add to mine.

    DISM – Step #5 – Adding Drivers to WinPE

    DISM /image:c:winpe_x86mount /Add-Driver /driver:C:YOUR_FOLDER_OF_INF_DRIVERS /recurse

    A nice addition to DISM over the previous peimg command in WINPE 2.0 is the ability to add drivers with the /recurse command. The /recurse command now allows us to simply have all of our drivers in their own directory and tell DISM to scan the root folder and everything beneath it. The number of sub directories won’t matter. I have a huge library of drivers, for example, you will want to have the network and vga drivers for anything that you boot up to in the WinPE environment. By adding the network driver to your WinPE boot environment, it allows you to access network shares for capturing and deploying .wim images.

    DISM – Step #6 – Adding Custom Scripts, Batch Files, Etc.

    xcopy /e /y “C:YOUR_FOLDER_OF_SCRIPTS” C:winpe_x86mountWindowsSystem32

    Without adding anything to your WinPE boot environment you will simply be left with a command prompt window when booting to it on a computer. I have added over 15 different batch scripts with different functions. Click here to download my WinPE discs. One thing I highly suggest adding is GImageX. GImageX is a very small GUI program that you can add to be able to capture, deploy, and mount images within the WinPE boot environment. I have provided a picture of GImageX GUI below.

    For WinPE 3.0 Boot Environment - Mount, Deploy, Capture Images

    For WinPE 3.0 Boot Environment - Mount, Deploy, Capture Images

    DISM – Step #7 – Unmounting your finished .WIM

    Dism /Unmount-Wim /MountDir:C:winpe_x86mount /Commit

    This commits the final changes to your .WIM file and anything you added to it. It is very important to unmount your .WIM file when you have finished.

    DISM – Step #8 – Copies your .WIM to Boot ISO

    copy c:winpe_x86winpe.wim c:winpe_x86ISOsourcesboot.wim /Y

    DISM – Step #9 – Creates bootable .ISO of WinPE 3.0

    oscdimg -n -bc:winpe_x86etfsboot.com c:winpe_x86ISO c:winpe_x86winpe_x86.iso

    Now, if you are wanting to use a flash stick you will need to format a flash stick in a certain way, and then simply copy the contents of the c:winpe_x86ISO to your flash drive. And thats it! Stick it in a computer, restart, and boot to it. The .ISO made in step #9 can simply be burned to a CD with Nero or other program capable of making bootable CD and then you can boot to it in the same way.

    DISM – Step #10 – Optional Backup

    xcopy /e /y “C:winpe_x86″ E:BACKUP_FOLDER_FOR_LATEST_BOOT_BUILD

    This step is optional, but I always like to keep a backup for the future. Also, if you ever need to create another bootable flash stick or CD you can simply go to your backup and grab the files.

    Tags: , , , , , , ,

    134 Responses to “Deployment Image Servicing and Management (DISM) – WinPE 3.0 Boot Environment”

    1. Paul says:

      I’m also a newbie to the whole WINPE deployment and imaging myself. Was too busy to get out of Ghost, but done with it.
      I was stuck on step 4 for a while, so ., I’m using Win 7, its not command line , we are using power shell, it has expanded capabilities it ain’t that a simple command prompt.
      Opened explorer and dragged the file to the command prompt and this fixed it for me.
      Dism /image:C:\winpe_x86\mount /Add-Package /PackagePath:[DRAG FILE FROM EXPLORE BROWSER HERE]
      It looks exactly the same but it works.
      Technical: probably some under the covers powershell code that translates the path to short format.

    2. @Roger Z: First off, what types of machines are they? Are they Dell? Custom?

    3. ash says:

      Brian,
      Don’t bother trying to decipher my comment. I think I’ve untangled my messy thought process.

    4. Blake says:

      Hey Brian I am a newbie in the WinPE world I have built a bunch of Bart’s cd but never messed with winpe.

      My question is this I come from a ghost shop and we are still using with our xp images along with a sysprep answer file.

      I followed this guide and I am not sure what is next I have also formatted my flash drive with the other guide.

      If I could get some help I would Rock.

      Thanks

    5. Nick says:

      Hi Brian,

      Having same exact issue and errors as “Brian Z” Machine I am using is an E6400 Dell Latitude. I did inject your drivers into the WinPE process per your instructions. Thank you for the great work here. Am a noob to WinPE myself.

    6. @Roger Z: Sorry for the delay in my response, I have been swamped between work, school, and my own personal projects. I am curious to know which mode your hard drives are running in. In your BIOS, are you running IDE mode / SATA / AHCI / or IRRT? Might try another mode really quick and see if that fixes your problem.

    7. @ Lance Haig : Are you referring to Windows System Image Manager?? If you have a x32 bit computer, you use the x86 components. If you have a x64 bit machine you use the amd64 components. If that wasn’t your question, just let me know.

    8. I followed the steps and everything worked perfectly. When I booted from the USB drive I made and formatted using your steps I get an error. It says the file iastor.sys is missing from system32….. this seems strange. Is there something I am missing?

    9. Faraz Shaukat says:

      Hi,
      I am trying to maintain the administrator account (has been renamed this in the base image and added stuff to the desktop) & profile when I create my image.
      When I run sysprep it deletes the admin account.
      What can I do to maintain that admin account when I run sysprep ?
      Thanks,
      Faraz
      p.s. Everything else works great …awesome instruction set.

    10. manikandan says:

      is it possible to add windows critical updates in install.wim using dsm, which in the format of .exe

    11. My brother in law would fall in love this website. We were not too long ago speaking about this. hehe

    12. PSD says:

      winpe.bmp file, as provided in your scripts/batch files, doesn’t load. Is there something that is missing, that I missed? This is 32bit version. All I get is a black screen.

    13. ws2000 says:

      Since I upgraded to WinPe 3.0 I have not been able to successfully use startnet.cmd to call a batch file on boot up to identify my drive letter. The small DOS like box comes up as usual and you see it runs my batch file and then it immediately reboots WinPe. This process worked fine under WinPE 2.0 and 2.1. Below are variations I have tried in my Startnet.cmd file

      startnet.cmd (1)

      wpeinit
      call mstart.bat

      startnet.cmd (2)

      wpeinit
      mstart.bat

      startnet.cmd (3)

      wpeinit
      @echo off
      cls
      Goto Begin
      :Begin
      ECHO FINDING BOOTABLE DRIVE
      FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\WinPE_Boot_Media.txt SET DRIVE=%%i:
      %DRIVE%\menu.bat
      goto END
      :END

      Does anyone know why or what is causing WinPe to reboot after I call a batch file or running a script from Startnet.cmd. I am completely stumped ?!?!?!?!?!?!

      Thank you

    14. AssistancePls says:

      Brian, great tutorial BTW. I followed it to a tee and I seem to be getting stuck at the most crucial part for me, and the only real reason I need a WinPE. Gimagerx. I boot up from my USB stick and run your script. After choosing option 2 gimagerx I get nothing.
      Thanks!

    15. Jay says:

      OK, so I have an old PE disk that someone created at my work where we have 5 static IPs that we can use for these disks. How can I setup the new PE 3.0 to use 1 if not have the option to choose from 5 different static IPs?

    16. @PSD: Do you get the rest of the scripts working and only the background doesn’t show up? Normally if the background is black it simply means a step was missed or done wrong and the WinPE environment resets to default without any of the configurations you want in it. I have had that happen before. I would walk through all the steps again carefully and make sure you didn’t miss one.

    17. @ws2000: At short glance I don’t see anything wrong with your script. Are you still having the same problems?

    18. @AssistancePls: Have you edited the gimagex.bat in my zipped folder? because i left that open for editing.

      net use Q: \\IP_ADDRESS\FOLDERSHARE /user:USERNAME

      You will want to put in your destination IP, or you can simply delete that line in the script if you are just going to go to external hard drive. Ask if you need more help.

    19. Jay F says:

      Where do your files go in the mount folder?

    20. Steve says:

      Brian,
      I am having the exact same issue as Roger Z posted earlier. I will try to post some of the details he did not replay with.

      My Windows 7 Professional x64 image was created on a Dell Optiplex 755. The hard drive is in “Raid Autodetect/AHCI” mode in the BIOS. I used your USB boot tool to wipe the drive of a Optiplex GX620, apply the captured WIM, at which point the machine is rebooted and boots to “Bootmgr missing”. I attempted to run option 6 on your USB boot tool, but that the error Roger Z posted. The optiplex GX620′s harddrive is simply “Sata”. Changing to “Legacy” and reapplying the image did not resolve.

    21. Michael says:

      Im confused on step 4. What exactly do I type? The command is not reconized when I type what you have there. I know Im missing something just not sure what it is. Any help would greatley appreciated.

    22. PSD says:

      Brian. With regard to the winpe.bmp file displaying… What I discovered was that the BMP file in the 32bit bundle was 2.3mb in size. Whereas the winpe.bmp in the 64bit version was a little more than 700k. Building a 64bit version worked fine. Using the 2.3mb winpe.bmp in the 32bit version, when unmounting and committing the changes, ended up with a 1k file size. And, scripts worked, but screen was black. When I used the 700+Kb winpe.bmp from the 64bit bundle in the 32bit build, I got the blue background fine. And, on viewing the mounted wim, filesize was correct. Either a bug in the bundling unmounting of file?, or that size was causing a problem? Don’t know. But, with the smaller file, everything works. So, I’m sticking with that, and will try a few other things later. Your instructions are very much appreciated! I appreciate someone documenting these steps, so I can come back to it, once I’ve forgotten the steps again!:-)

    23. @Steve : I’m assuming you got this problem fixed with the “boot” checkbox in Gimagex?

    24. @Jay F: Your files should go in the C:\winpe_x86\mount folder. You can simply put them in the root of that folder.

    25. Dism /image:C:\winpe_x86\mount /Add-Package /PackagePath:”C:\Program Files\Windows AIK\Tools\PETools\x86\WinPE_FPs\winpe-wmi.cab”

      I am pretty sure these aren’t required to perform what we are needing to do. Try skipping step #4 and you should be ok.

    26. @PSD : Glad you figured that out. I will make a note of that in my documentation.

    27. Bob says:

      Hi Brian,

      Great tutorial!!! :) Imagex seems to be very slow capturing the image to my portable WD passport compared to using ghost.
      I haven’t tried saving it to the network yet, I’ll presume capturing the image to a local portable USB drive would be faster or not? please let me know what your thoughts..

    28. @Bob: What compression rate are you running it at?? None, Fast, or Maximum? That makes a lot of difference. There is a dropdown box for that in the GimageX application right under the description field. Capturing images should be pretty fast, but it does depend on the size of your hard drive. I have noticed that image captures with GimageX in general are slightly slower, but it makes up for it because of useability. Deploying images are amazing fast. I just deployed a universal windows 7 x64 bit image today to a Dell Optiplex 755 over gigabit connection in under 3 1/2 minutes. Can’t beat that!

    29. Bob says:

      Thanks Brian, I used the maximum compression. I might try the fast compression and yes! I totally agree GimageX is lightning fast when deployed….

      Cheers

    30. daniel says:

      Hi, i found that i have no problem of creat/amend wim based on my C driver, however when i us ethe PE to format C: and apply the wim to the C driver, after applied, the C: can’t boot up, which it said the winload.exe is corrupted and show 0xc000000e , how can i avoid that? many thanks!

    31. daniel says:

      i remember i have the same output if i use ghost to clone the windows 7

    32. Al says:

      Thank you so much Brian, I am a noob with WInPe it’s ridiculus. I’m trying to get move our shop away from Ghost as well. Everything work except that when using Gimagex to create the image its taking an ungodly amount of time. I belive it is the nic speed and duplex setting. We run cisco hard coded ports to 100/full. When one of our pc’s is set to auto, copying to a network location is ridiculously slow so we have to hard code the pc’s to 100/full. Is there a command or utility I can use to change the linkspeed/duplex setting while within the winPe session? Also, where would I change these settings in your drivers you provided to hardcode this setting. And further, is there a way to enable or access a GUI version in Win PE to view the NICs and change their settings?

      Thank you so much for you assistance and this great work!

    33. bkz81 says:

      Hi Brian. Thanks a lot for the guide on this. I do have one small problem though. I followed everything on the guide, and added the scripts and drivers. However when i boot off the CD i get a DOS screen with the path of “X:windows\system32″ Where do i go from here to get to gimagex or any of the scripts? thanks.

    34. Tony says:

      Just a note about audit mode-

      If you let the computer go to sleep, you can’t get back in because the adminsitrator account is technically disabled and there are no other accounts on the machine at that time.

      A forced shutdown (holding the power button) and reboot gets you back in.

      It seems the security screen does not really know about the maching being in audit mode.

      I’ve changed the “plugged in” option to never go to sleep :)

      thanks Brian for this incredible resource!

    35. Bob says:

      Hi Brian,

      Can you use this WinPE to capture and deploy Windows XP SP3?

      Any, issue if I sysprep the image and use imagex I’m not sure if this is also design for windows Xp or just Windows 7.

      Thanks

    36. [...] blog from a guy named brian – nice walkthroughs [...]

    37. PaulW says:

      Hey Brian, Great Tutorial – I am however running into one initial problem. I’ve created several boot disks with imagex but when following this tutorial I get an “The file “Autorun.dll” could not be loaded or is corrupt. Setup cannot continue. Error code [0xE0000100]“. I thought it was because I was running the 64 bit system (even though im imaging brand new z800 hp’s) but it also failed on the x86. Any suggestions? Thanks!

    38. DanC says:

      Hey Brian,

      Totally new to this stuff. We will be deploying some windows 7 machines this summer in our district. You suggest going the bootable flash drive route. Any instructions for a bootable CD/DVD? Is it TOO HARD ??? Any info you provide is appreciated! Thanks!

    39. DanC says:

      Ahhh…I see where I can burn a CD. Though are there standard drivers I should be loading into this image. I’m guessing I want network drivers, display drivers, VGA?? for ALL machines I will need to boot into the PE environment????

    40. PeterIT says:

      Great instructions. However, when I tried your steps and after booting the PC with USB, select (2) did not give me the GImagex windows even through I modified your script to remove “net use Q: \\IP_ADDRESS\FOLDERSHARE /user:USERNAME” line. Thanks for your help!

    41. PeterIT says:

      Never mind my question, I already figured it out. Thanks! :-)

    42. DanC says:

      Brian,

      I’ve gotten past my two issues from Feb. 26th. Though I’m at the same screen when booting from CD as bkz81 is at. When booting from the CD, I hang at:
      “X:windows\system32>wpeinit” Then I get no further. Any help would be appreciated. thanks!!

    43. JaneY says:

      I have the same issue as DanC and bkz81. Mine hangs for a minute at the wpeinit but then gives me the prompt shortly there after. I’ve gone through the process twice, it’s as if our custom .wim settings were not included in the iso build…if you list the contents of the %dir%\system32\ the startnet.cmd is the default one and not the customized version, also, none of the custom scripts have been added to the sys32 directory either…. Your site is great, I’m so glad I stumbled upon it. Thank you for sharing your knowlege and expertise

    44. Chip M says:

      Wonderful guide. I’d be lost w/out it. I have built a WinPE disc following all steps listed. When I boot from it however, a Windows 7 installation screen is displayed prompting for language selection. What am I missing? Thanks so much.

    45. StevenLChan says:

      Hi Brian,

      I too am having the “Bootmgr missing” after applying a captured .wim image. I’ve clicked on the “Boot” checkbox prior to capturing the image.

      Could it be that under Windows 7 installation, the 100MB system reserved partition is confusing it?

    46. Chip M says:

      Figured out my issue. Startup.exe file got added to the \mount directory somehow. Once I deleted the file, WinPE booted as it should.

    47. matt says:

      I was having the same problem that Paul was having in step #4.

      The problem was that when I cut and pasted the command from the browser, the quote mark looked normal on the command line, but was actually a different character.

      I discovered this when I pasted the command into notepad and typed a quote next to it.

    48. Chip M says:

      RE: the “Bootmgr missing” message, try the following:

      after the image is applied, return to the imager, select command prompt & enter bcdboot C:\Windows

      More on BCDboot: http://go.microsoft.com/fwlink/?LinkId=121711

    49. Peter404 says:

      Hello Brian
      In step 3, I’ve an error : 0xc1420114
      Directory not empty. This operation is not allowed (translate from french ,^)
      Have you any idea ?
      Thanks

    50. Peter404 says:

      Hello Brian
      Forget my precedent post: i ve forget the \mount because it’s at the new line
      thanks

    Leave a Reply