Tuesday, August 12, 2008

Mount ImageX WIM’s via Windows Explorer

This is a “by-request” post for the D-Man.

We were talking in my cubicle/bullpen the other day about images and how files can be extracted from within them for recovery or troubleshooting purposes.

For instance, Symantec Ghost has Ghost Explorer.

And ZENworks Imaging has ZENworks Image Explorer.

Well, you might not have known it, but ImageX users can also mount and explore/extract files from a WIM image.

Here’s how.

Get the Windows Automated Installation Kit and Install

Take your pick:

Download details: Windows Automated Installation Kit (AIK)

Download details: Automated Installation Kit (AIK) for Windows Vista SP1 and Windows Server 2008

The first is the original, the 2nd incorporates the Vista SP1 updates in the WinPE 2.0 (and then some) files.  You don’t need both.  Either will do.

Once downloaded, mount the ISO using a utility like SlySoft Virtual CloneDrive. Or burn the ISO to CD, then turn around and install it.

Note:  from what I read, if you are clever, you can also just snag a copy of the following files from the C:\Program Files\Windows AIK\Tools\x86 (for x86 OS’s) or from C:\Program Files\Windows AIK\Tools\amd64 or C:\Program Files\Windows AIK\Tools\ia64 for the appropriate 64-bit OS processor type folder where the WAIK has been previously installed on another system.  I prefer just to install the WAIK package myself.

  • imagex.exe
  • wimfltr.inf
  • wimfltr.sys
  • wimgapi.dll

Install the WIM Filter

For some reason installing the WAIK does not install the WIM filter your system needs running to mount/manage WIM file images.

To do that you need to again browse to to C:\Program Files\Windows AIK\tools. Pick the right sub-folder for your CPU type.

Now, right click on wimfltr.inf and then click on “install”. Reboot. 

This shouldn’t require Administrator privileges to do, but if you have problems, try that instead.

For more details see this post: 4sysops - How to mount a WIM image with ImageX in Windows Vista

Add WIM Filter Options to Windows Explorer

So to make this convenient, I find it very helpful to add a registry hack that puts the WIM filter options in the Windows Explorer’s right-click context menu so I can quickly mount/dismount WIM files from Windows Explorer on the fly.

Jump over to Robert Law’s post: Mounting WIM Images from Windows Explorer - Robert McLaws: Windows Vista Edition  (Note: Works on XP and Vista systems.)

Download the appropriate REG file from his site,

Add a “mounted_wim” folder at the root of your system partition –> C:\mounted_wim

Run the REG file you downloaded.  Reboot.

Then to see if it worked, browse to C:\Program Files\Windows AIK\Tools\PETools\x86 and look for the winpe.wim file.  You should now see a pretty icon and if you right-click it from within Windows Explorer, you should see options to “Mount, Commit Changes, Dismount, and Mount Writeable.”

Pretty Cool!

Possible Gotcha!

When preparing this post, I wanted to make sure it still worked as described.

I was using the x86 versions and for some reason, it never did.

I did some looking around and it seems like the REG file downloads from Mr. McLaws sites might actually be corrupted.

I compared the wim-x86 version I was getting downloaded and it seemed to have some corruption in the text.  It just didn’t look right.

The MD5 hash I get from his file dated 11-04-07 is 0b0cd1941bdae4ab24feb31f65f74ca8

The MD5 hash I get from the one that I downloaded months ago and DOES still work is:
1b87e35ee51998b26a8e1a4853cfdf0f.

I’m getting the “corrupted” version on all my systems when I try to download it, independent of browser used.  I’m not sure if this is just something crazy I am running into or a real issue with the files he is hosting.  So you may find different. I just can’t say yet.

I dropped Mr. McLaws a line to see if he can confirm.  I’m waiting for his response.

In the meantime, below is the contents of the working version of his wim-x86.reg file that I have.  Alas, I don’t have one for the x64 file.

If you experience the same thing that I was, you might want to try making a blank wim-x86.reg file in Notepad.  Then copy the following text into it and save.  This might work in the meantime.  Also, this is all Robert’s work.  I’m just passing it on for folks having problems with the current downloadable version from his site…all credit where due!

wim-x86.reg contents

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\DefaultIcon]
@="C:\\Program Files\\Windows AIK\\Tools\\x86\\imagex.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell]
@="Mount"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell\Commit]
@="Commit Changes"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell\Commit\command]
@="\"C:\\Program Files\\Windows AIK\\Tools\\x86\\imagex.exe\" /unmount /commit c:\\mounted_wim"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell\Dismount]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell\Dismount\command]
@="\"C:\\Program Files\\Windows AIK\\Tools\\x86\\imagex.exe\" /unmount c:\\mounted_wim"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell\Mount]

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell\Mount\command]
@="\"C:\\Program Files\\Windows AIK\\Tools\\x86\\imagex.exe\" /mount \"%1\" 1 c:\\mounted_wim"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell\Mount2]
@="Mount Writeable"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Windows.Image.Format\shell\Mount2\command]
@="\"C:\\Program Files\\Windows AIK\\Tools\\x86\\imagex.exe\" /mountrw \"%1\" 1 c:\\mounted_wim"

[HKEY_CLASSES_ROOT\.wim]
@="Windows.Image.Format"

Alternative #1 – Via the CLI

If you don’t want to do this registry trick, just mount your WIM files from the command line.
Windows IT Pro has a great and simple guide:

Alternative #2 – Via a GUI Utility

ImageX is pure command-line kung-fu.  However, Jonathan Bennett has developed a wicked-cool GUI utility that can also be used to do this.  I like Robert’s method, but if you want, this little guy should do the trick.  Note: since I have already installed the WAIK and WIM Filter before using this, I can’t say for certain that it will work without all that jazz.  I would recommend doing so (as described above) before you use this tool, just in case.

Current version was just updated to v2.0.13 as of July 4th, 2008.  So keep an eye open for more updates down the road.  This version is much more robust and feature-rich than the early versions I encountered back when I was getting my feet wet in ImageX usage.

Cool Curiosities for PC Sysadmins

While doing the troubleshooting (before I located the bad REG file), I thought that maybe I had to install the wim filter via an admin account.  As I was using one of the IE App Compat VHD virtual images, it provides a limited user account by default so I wondered how I could install it with Admin rights.

I had already obtained this VHD’s Administrator account password…somehow!

I knew I could do the “run-as” command to elevate but that didn’t work for this particular situation with the wimfltr.inf file.

I could do a “run-as” elevation of CMD as administrator easily enough…which I did.  But can you install an INF driver from the command line and not the GUI?

Yep!

Install INF Drivers From Command Line or Script – Dashken’ I-Blog held the answer.  And dealing with the WIM filter no less!  Definitely worth bookmarking!

See also this MSDN page: InstallHinfSection Function (Windows)

The trick here is in the guide where you see the <filename.inf> noted for you to type, you must type the FULL CLI path\filename.inf, not just the filename.inf for it to work.

Example, to install the x86 WIM Filter system service do this:

%SystemRoot%\System32\rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 C:\Program Files\Windows AIK\Tools\x86\wimfltr.inf

OR

C:\Windows\System32\rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 C:\Program Files\Windows AIK\Tools\x86\wimfltr.inf

NOT

%SystemRoot%\System32\rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 wimfltr.inf

OR

C:\Windows\System32\rundll32.exe setupapi,InstallHinfSection DefaultInstall 132 wimfltr.inf

Even if you have the CLI open to the location of the wimfltr.inf file itself.

Clear?

Next find, I wanted to actually work on the IE Tester’s “Administrator” desktop account workspace, but short of booting in Safe Mode, I couldn’t initially get to it.

The first workaround I did to get to the full Administrator account on this free virtual hard-drive image was to download Process Explorer and then use it’s “Switch User” option from the menu bar.  I suppose I could have tried Ctrl-Alt-Del as well.

However, Process Explorer’s user-switching worked and quickly I was logged on to the Administrator desktop.

But I would have to do this at every reboot.

What if I wanted the Administrator login to show at boot?

Yep….one more registry hack.

That did the trick!  Now I can not only log on as the IE Tester user for regular work, but if I have to install or do something with “full” rights, I can choose to log on to the “Administrator” profile as well.

Sweet!

--Claus

No comments: