.\Matthew Long

{An unsorted collection of thoughts}

Edit the registry contained in a Wim File

Posted by Matthew on January 13, 2011

I’ve been asked recently to document how you can change registry hives contained within a WIM file.  This could be used either to make changes to a user account (such as the registry of the default user) or to edit the system registry settings.

The basic process for this is actually very simple, all we need to do is mount our WIM file.  Once mounted, we can use the reg command to load the hive into the live system’s registry, and make the required changes. Finally, we need to unload the registry hive and then commit the changes back to the WIM.

Obviously access to DISM is a requirement for this operation.  This can be located in the Windows Automated installation Kit.

Note : If you want to know where I got the Software registry hive location from, you can find HKey_Local_Machine registry hives in the C:\Windows\System32\Config folder.  The hives are named as they appear in Regedit.

  • Open the Deployment Tools Command Prompt (Contained in the Microsoft Windows AIK folder on your start menu)
  • Mount your wim file, by entering the below command .  Substitute the filename, index and mount directory for your wim filename and image index.  The mount directory just needs to be an empty pre-existing directory.

dism /mount-wim /wimfile:C:\WimImages\Win7.wim /index:2 /mountdir:C:\AIKMount

  • Once DISM reports that the image has been mounted successfully, you need to mount the registry.  I’m going to mount the wim’s HKLM\Software hive in this example.  You’ll notice the root of my reg path below is the folder I mounted the WIM into, given in the previous command.  Type

reg load HKLM\WimRegistry c:\AIKMount\windows\system32\config\software

  • If you now open RegEdit you will now see under HKey_Local_Machine\WimRegistry your registry hive.  You are now free to make your required changes.
  • Once you are finished, exit Regedit.  We now need to unmount the registry hive, which can be accomplished by typing

reg unload HKLM\WimRegistry

  • Now we need to unmount your wim image and commit the changes back into the .wim file.  To do this, type in

dism /unmount-wim /mountdir:C:\AIKMount /commit

And once DISM has unmounted the image, you’re done!  If you decided not to keep the changes you made (or didn’t make any and were just poking around in the reg) you would use the /discard switch instead of /commit

3 Responses to “Edit the registry contained in a Wim File”

  1. nickjennings88 said

    Hi Matt,

    Thanks for the great info.

    In the first dism command of this guide though, the /mountwim needs to be hyphenated. It will only work as dism /mount-wim

    Thanks again,

    Nick

  2. Jacob said

    I’ve used gimagex to mount / unmount wim, “reg unload HKLM\WimRegistry” is required before committing changes for me

    Jacob

Leave a reply to nickjennings88 Cancel reply