Creating a WIM the quick way...
IMAGEX is a fantastic tool, but it has a command line that can, at times, be way too complicated. As of yet, there is no official, nice, easy-to-use interface or GUI to simplify the whole thing although a couple of people have posted DIY ones on the web with various levels of success.
My current client needed a simplified way of creating a WIM file for use during the BDD project I am working on; they are using WIM files as a means of applying files to a computer, similar to just creating a ZIP file and extracting the contents. Anyway, I was asked if Microsoft had something (or could create something) that he could give to a junior member of staff so that s/he could create these WIM files without making mistakes or getting confused with the command line. So, I created a very simple HTA file which will do exactly what he asked for. Seeing as he liked it so much I thought that I would share it here so that others can take advantage of it.
Feel free to use/abuse/butcher/amend/correct/revise/recycle any or all of the code for your own use. Of course, I must mention the usual disclaimer: USE AT YOUR OWN RISK! THIS IS NOT 100% TESTED CODE.
Unfortunately, it does come with 3 requirements. The first is that it is run with administrative permissions. This is not a problem with Windows XP if you are an admin on the box but with Windows Vista you'll need to run it elevated (Windows Vista does not give you the "Run as Administrator" option for HTA files so you'll need to elevate a cmd prompt first, then run the HTA. The second is that you have the file imagex.exe in the same folder as the HTA file, and the third is that you have already installed the imagex filter driver. Installing the filter driver is easy to do, either install the WAIK on your computer or just right click on the .inf file which you will find in the same folder as imagex.exe on a computer that has the WAIK installed and choose "install".
To use: simply copy the code below and paste it (careful with the wordwrap)into notepad. Save the file with the .hta extension and then you are ready to run it, a simple double-click and you are away! Enjoy.
<head>
<title>WIMCreator</title>
<HTA:APPLICATION
APPLICATIONNAME="IMAGEX - CAPTURE HTA"
MAXIMIZEBUTTON="NO"
MINIMIZEBUTTON="NO"
SCROLL="NO"
SHOWINTASKBAR="YES"
SINGLEINSTANCE="YES"
WINDOWSTATE="NORMAL"
SYSMENU="YES"
>
</head>
<script language="VBScript">
Sub Window_onLoad
Dim path
Set fso = CreateObject("scripting.filesystemobject")
path = fso.getabsolutepathname(".")
CurrFolder.InnerHTML = CurrFolder.InnerHTML & " " & path
if fso.FileExists(path & "\imagex.exe") = false then
Msgbox "IMAGEX.exe does not exist in the same folder as this HTA program."
ImageXExists.checked = false
savefolderbox.disabled = true
savefolderbutton.disabled = true
driversbox.disabled = true
driversbutton.disabled = true
clearvalues.disabled = true
createwim.disabled = true
commentbox.disabled = true
else
ImageXExists.checked = true
end if
End Sub
Function BrowseForSaveLocation
On Error Resume Next
Dim oShell, oFolder, intColonPos, oWshShell
Set oShell = CreateObject("Shell.Application")
Set oWshShell = CreateObject("WScript.Shell")
Set oFolder = oShell.BrowseForFolder(0, "Choose WIM destination folder", &h17, OPTIONS)
BrowseForFolder = oFolder.ParentFolder.ParseName(oFolder.Title).Path
If Err.Number > 0 Then BrowseForFolder = Null
If oFolder.Title = "Desktop" Then BrowseForFolder = owshshell.SpecialFolders("Desktop")
intColonPos = InStr(oFolder.Title, ":")
If intColonPos > 0 Then BrowseForFolder = Mid(oFolder.Title, intColonPos - 1, 2) & "\"
savefolderbox.value = BrowseForFolder
End Function
Function BrowseForDrivers
On Error Resume Next
Dim oShell, oFolder, intColonPos, oWshShell
Set oShell = CreateObject("Shell.Application")
Set oWshShell = CreateObject("WScript.Shell")
Set oFolder = oShell.BrowseForFolder(0, "Choose source folder", &h17, OPTIONS)
BrowseForFolder = oFolder.ParentFolder.ParseName(oFolder.Title).Path
If Err.Number > 0 Then BrowseForFolder = Null
If oFolder.Title = "Desktop" Then BrowseForFolder = owshshell.SpecialFolders("Desktop")
intColonPos = InStr(oFolder.Title, ":")
If intColonPos > 0 Then BrowseForFolder = Mid(oFolder.Title, intColonPos - 1, 2) & "\"
DriversBox.value = BrowseForFolder
End Function
Sub ClearVals
savefolderbox.value = ""
driversbox.value = ""
commentbox.value = ""
End Sub
Sub CloseHTA
self.close
End Sub
Sub CaptureWIM
Dim path
Set fso = CreateObject("scripting.filesystemobject")
path = fso.getabsolutepathname(".")
Set oWshShell = CreateObject("WScript.Shell")
Dim imgCMD
imgCMD = path & "\imagex.exe /capture " & chr(34) & driversbox.value & chr(34) & " " & chr(34) &
savefolderbox.value & "\mywim.WIM" & chr(34) & " " & chr(34) & commentbox.value & chr(34)
oWshShell.Run imgCMD, , True
End Sub
</script>
<body>
<span><span><span style='font-family: Arial'><span style='font-size: 10pt'>
<span id = "DataArea">Welcome to the WIM creation tool! This tool Is NOT an official Microsoft product and
this therefore totally unsupported.<br />
<br />
You must execute this program with admin rights!</span><br />
<br />
<hr />
<br />
<span id = "CurrFolder">Current directory:</span>
<br />
<br />
IMAGEX.exe found?
<input id="ImageXExists" type="checkbox" name="imagexexists" checked="CHECKED" disabled="disabled" /><br />
<br />
<hr />
<br />
</span></span>
</span></span>
<span style='font-size: 10pt; font-family: Arial'>
Path to source folder<br />
</span><input id="DriversBox" name="DriversBox" style='width: 617px; font-size: 10pt; font-family: Arial;'
type="text" readonly="readOnly" /><span
style='font-size: 10pt; font-family: Arial'> </span>
<input id="DriversButton" type="button" value="Browse..." name="DriversButton" onclick="BrowseForDrivers"
style='font-size: 10pt; font-family: Arial' /><br />
<br />
<span style='font-size: 10pt; font-family: Arial'>
Location for WIM file to be saved<br />
</span>
<input id="saveFolderBox" name="saveFolderBox" style='width: 617px; font-size: 10pt; font-family: Arial;'
type="text" readonly="readOnly" /><span
style='font-size: 10pt; font-family: Arial'> </span>
<input id="saveFolderButton" type="button" value="Browse..." name="saveFolderButton"
onclick="BrowseForSaveLocation" style='font-size: 10pt; font-family: Arial' /><br />
<br />
<span style='font-size: 10pt; font-family: Arial'>Comment to be included in WIM file<br />
</span>
<input id="CommentBox" name="CommentBox" style='width: 617px; font-size: 10pt; font-family: Arial;' type='text'
value="my wim file" /><br />
<br />
<br />
<hr style='font-size: 10pt; font-family: Arial' />
<br />
<input id="CreateWIM" type="button" value="Create WIM" onclick="CaptureWIM" style='font-size: 10pt; font-
family: Arial" /><span
style='font-size: 10pt; font-family: Arial'> </span>
<input id="ClearValues" type="button" value="Clear Values" onclick="ClearVals" style='font-size: 10pt; font-
family: Arial" /><span
style='font-size: 10pt; font-family: Arial'> </span>
<input id="Exit" type="button" value="Exit" onclick="CloseHTA" style='font-size: 10pt; font-family: Arial'
/><span
style='font-size: 10pt; font-family: Arial'> </span>
</body>
P.S. I should mention that this was made for the creation of a WIM file based on a folder on your local filesystem. I have no idea, and it was not developed with this in mind, if you could capture an actual Operating System install with it; although I suspect you could...
Comments
Anonymous
January 01, 2003
The comment has been removedAnonymous
January 01, 2003
The comment has been removedAnonymous
January 01, 2003
p.s. I have attached to this post a working version of the HTA code. You can download the file and use that instead of copying and pasting the code.Anonymous
February 18, 2008
I tried this since I've been fighting with imaging and this seemed like a great solution. I made sure that all of the requirements you laid out were met but when I ran it it was coming back with script errors. I've been looking at your code for a while and I can't find anywhere that could be causing the problem. Any advice? Thanks MarcusWilliams@Mid-WaySupply.comAnonymous
October 23, 2009
The comment has been removedAnonymous
November 12, 2009
Sorry Daniel I guess I was not clear. I did not copy the text I downloaded the file hosted on this site named: WIMCreate.htaAnonymous
February 06, 2011
i love you