ImageX HTA with Win PE 3.0/4.0 x64/x86 Server 2008/R2 WDS Tutorial
#1
Posted 18 September 2009 - 01:27 PM
Update: Minimal changes needed for WinPE4 build, see here.
I will be using v7.1 version of the program as v9.0 and v9.1 are not functioning enough to use. If anyone wants to try making them work properly, I can add them into this project. See the following resource:
http://www.msfn.org/.../17-t97512.html
Last available versions
Version 7.1 :: download
Version 7.3 :: download from SkyDrive
Version 7.4 Beta Server HTA :: post
First, this is not a tutorial regarding how to set up the WDS on Server 2008. No questions regarding PXE or WDS errors will be permitted in this thread, only ones relating to the creation of the PE and actual use/behaviour of the HTA in the (booted) PE. Some of these instructions may be used to create this on a DVD, CD or a UFD if a network boot is not an option for you. The specifics of converting this to those methods are not permitted. If you have a question relating to this project but falls into the "non-permitted" category (outlined above), please make a new thread and refer to this topic.
This tutorial also uses the following constants. The Server being deployed from is Server 2008 Standard x64. I am also using the OPK Tools, and not the Windows AIK. As a result of these two things, the paths used in the examples below may be incorrect in your case. You may be using the AIK, or your program may have been installed into Program Files (x86). You need to be aware of these differences if they apply to you and adjust your commands appropriately. I am also using the RTM version of the OPK Tools for Windows 7 Enterprise/Server 2008 R2. There may be slight differences from the WAIK, or Release Candidate versions that I am not aware of. If a specific command is not working for you, check what you typed and then check to see if the commands I am using are valid for your version.
#2
Posted 02 October 2009 - 12:40 PM
copype.cmd amd64 c:\winpe_amd64 xcopy c:\winpe_amd64\winpe.wim c:\winpe_amd64\ISO\sources\boot.wim Dism /Mount-Wim /WinFile:c:\winpe_amd64\ISO\sources\boot.wim /index:1 /MountDir:c:\winpe_amd64\mount Dism /image:c:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\tools\PETools\amd64\WinPE_FPs\winpe-hta.cab" Dism /image:c:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\tools\PETools\amd64\WinPE_FPs\winpe-mdac.cab" Dism /image:c:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\tools\PETools\amd64\WinPE_FPs\winpe-scripting.cab" Dism /image:c:\winpe_amd64\mount /Add-Package /PackagePath:"C:\Program Files\Windows AIK\tools\PETools\amd64\WinPE_FPs\winpe-wmi.cab" Dism /unmount-Wim /MountDir:c:\winpe_amd64\mount /commit
This adds the HTA, MDAC, Scripting and WMI packages. The MDAC may or may not be required for you, but not having it only can limit future development. Check out the Windows PE User's Guide (in the Start Menu) for more information on each package and how to add them.
At this point, you should test your new PE that you made to make sure it works. You may skip this step if you feel sure about it. You will need these steps when you are finished with your PE anyways. The following also assumes a currently active WDS, and these steps will imply that.
Update 10-05-09: It seems there was a step left out of the MS instructions. You need to take the files from C:\Program Files\Windows AIK\Tools\amd64 and put them in c:\winpe_amd64\mount\Windows\System32 if you want to have access to Imagex.exe!
1. Open Windows Deployment Services as Administrator (runas)
2. Expand your server you want to use until you see the containers inside.
3. Right-click on the Boot Images container and click Add Boot Image.
4. Browse to your PE location (look above if you forgot) choose it.
5. CLick next to the Name and Description page. I try to make things easy for my directed audience, so I will rename each line to "Imagex (x64)"
6. Keep clicking Next until it loads it and then Finish.
Last step, boot a client to the network and choose the new Imagex (x64) if you have a menu, if not it should boot right in.
Next we will put the HTA into the image. I've already gone through the liberty of figuring out how to get this working before writing up this post.
First, make a folder to extract (or copy to) the files from the v7.1 zip file. If you have a customized one like I do, that's fine, or you can customize it ahead of time too, or leave it at stock. Up to you. There are a few things we need to make or get before we can put this in the Boot.wim.
In order for this to work in x64, we need the new GimageX COM files. Not only is there one for x64 but also it is updated to handle Windows 7. Download the full package here:
http://www.autoitscript.com/gimagex/
After you get this, you need to extract it out. You will find a COM folder and an x64 folder with the gimagex_com.dll inside. Copy this one and replace the one in the v71 folder.
The second thing we need to take care of is the BROWSE.EXE program. You may choose to skip this step if you want to test to see if it works anyways. For me, it did not work until I decompiled it and recompiled it for x64. In order to do this, you need to download (or have installed) AutoIT v3.
http://www.autoitscript.com/autoit3/
Once installed, in the start menu in the AutoIT folder you will find a program called "Decompile .exe to Script". Open this up and point it to the BROWSE.EXE in the v71 folder. In the second box you need to pick a name to save it as, which should be BROWSE.AU3. After it does this, go back into the AutoIT Start Menu and find a program called "Compile Script to .exe". Same concept, first line you choose the BROWSE.AU3 and second you choose the BROWSE.EXE that was already there. Make sure to choose the x64 radio button. In this step you will be overwriting the original BROWSE.EXE (the 32bit one) from the zip file. This is fine because if you want the original one back, just get it out of the Zip again!
A little note about the Decompile .exe to Script program. It is used to decompile .EXE files compiled with AutoIT. This does not mean you can decompile any AutoIT based .EXE, just ones that have no password on them. Fortunately, Geezery did not put a password on his EXE so we can decompile it to make it 64bit.
Now we are ready to make the Startnet.cmd file. This is what mine looks like on my test server:
wpeinit wpeutil initializenetwork ping 127.0.0.1 -n 16 -w 1000>null net use z: \\7SERVER\images ZarleyZalapski33 /user:kdineen regsvr32 /s misc/gimagex_com.dll mshta.exe x:\windows\system32\imagex.hta
The ping command are in there to delay mapping of the network drive for systems with NICs on an initialization delay. NICs on boards such as the Intel DG45ID and DG45FC (among others) require this in order to be able to be able to map the drive properly. The command after is mapping to the network share where the WIMs are kept.
As you can tell, we are going to put all the files from inside the v71 folder into C:\Windows\System32. This includes the MISC folder and the Startnet.cmd! So here are your steps for updating the image with new files:
1. Mount the wim using the following command:
Dism /mount-wim /wimfile:c:\winpe_amd64\iso\sources\boot.wim /index:1 /mountdir:c:\winpe_amd64\mount
2. Next, copy all files from the v71 folder, including the startnet.cmd and paste into c:\winpe_amd64\mount\windows\system32. You may need to provide Admin Rights for replacing the startnet.cmd. After you do this, we are ready to save the image with the following:
dism /unmount-wim /mountdir:c:\winpe_amd64\mount /commit
3. Lastly we need to refresh the Boot image in WDS. From the WDS CPL, find your image under Boot Images, if named as in the tutorial it will be called Imagex (x64). Right-click on it and choose replace image. When you use the browse box, it will look at the last path (directory) you imported or replaced from the last time you used that option. So if you did nothing in WDS since adding the original Boot.wim, the one that appears when you hit browse will be the file we want. Select that, and go through the screens as you did the first time. It will default the Image name and Description, so you will have to change that again. After it is done and the Finish button lights up, you are good to go. You do not need to restart the WDS service, or refresh the window at all. Boot your client and see how it looks.
At this point in the tutorial, you should be able to capture XP, Vista, 2003 and 2008 images just fine. Windows 7 instructions will be added to this thread later.
This post has been edited by Tripredacus: 27 January 2011 - 11:06 AM
#3
Posted 02 October 2009 - 12:40 PM
#4
Posted 02 October 2009 - 12:40 PM
I have created a program that will install Windows 7 images from said sub-folders. I will not be able to post the source for that program or give instructions on how to deploy it because they are images with WinRE installed. I will now re-open this thread so that others can have a try at it.
Current Issues
1. Setres does not work, PE is 800x600.
2. Buttons at the bottom do nothing.
Starting with SetRes.exe, it is a 32bit EXE and does not work in PEx64. I found another program here that seems to work:
http://www.boot-land...?showtopic=2897
Put it in System32 and run using the following switches:
setresolution-x64.exe -r1024x768x32 -hide
Also, the shortcut buttons at the bottom do not work. I have 3 of them changed in my PE version, such as Capture, Mount and Map Network Drive. I run programs instead, such as Install XP Apps, Install Vista Apps and Deploy Windows 7. The command prompt button works, oddly enough, but the restart and shutdown buttons do not work either!
#5
Posted 15 October 2009 - 03:24 PM
I've been using it in house for awhile now.
This version runs under winpe 3.0 (x86 so far, I'll try X64 tomorrow)
The big changes I made to get it to run are.
The command window.confirm doesn't seem to work for me in pe 3.0 so they got replaced.
The xml for the wims are different, so I changed the way the program gets image names, the new way is much slower, but you can use it with new or old wims.
This version only support writing out images, giving a command shell, reboot, or shutdown. I made this for system builders to deploy images only.
If the Image description has the letters XP in it, the program will automatically put the nt52 bootsector on.
Hope this helps other people.
later,
dabone
This post has been edited by Tripredacus: 15 October 2009 - 07:48 PM
Reason for edit: Removed code for thread organization purposes
#6
Posted 18 October 2009 - 10:02 AM
The modification I did uses the gimagex com to select the image number then extract the imagename. It works with new and old and the mixed images I have generated. (I have quite a few images, 40 or 50 of them, so redoing them would be a pain).
To speed up the parsing of the xml file, would any of you real programmers care to write a parse routine that takes the raw xml data, then parse out the image number followed by the name? We already have all of the xml in memory, the original programmer just used the xmlcom method of grabbing image number followed by grabbing a specific child node for the name.
(Would love to get the windows version out also, so the boot sector type wouldn't be tied by name)
Later,
dabone
#7
Posted 18 October 2009 - 06:31 PM
I appreciate your feedback on this dabone. I am glad that my efforts (with Geezery's help!) has allowed us to even have this conversation. It is really a great application. And like you, I'm also not interested in starting over and using something else.
However, I have already accepted that I can make do with using the old PE to capture and the new PE to deploy XP, Vista and Windows 7. Either way, I won't kill the discussion, being able to select Windows 7 images like the older ones would be very helpful.
PS: I've never had to do the bootsect part. I've done XP and Vista from the same PE and never did bootsect... I know where this was proved to be needed otherwise, but I haven't encountered such a situation.
#8
Posted 20 October 2009 - 06:27 PM
It's just using string functions, I didn't bother trying to figure out that xml crap anymore.
It will handle mixed mode images (created with pe 2 and then appended with 3 or vice versa)
And its alot faster than using the gimagex com.
Do you mind if I post the new parsefile code here?
Later,
dabone
#10
Posted 22 October 2009 - 06:09 AM
This version of the sub will extract the image name where ever it is in the childnodes.
'****************************************************************************
'* parseFile
''****************************************************************************
Sub parseFile()
Set objSel1 = window.document.getElementById("select1")
objWIM.Source = myFilepath + objSel1.options(objSel1.selectedindex).text
objWIM.GetWIMInfo
strWimInformation = objWIM.XML
ImageCount = objWIM.ImageCount
Set xNodes = objXMLDocument.selectNodes("//IMAGE")
Dim strlen
Dim namestart
Dim nameend
Dim namepos
Redim strIndx(ImageCount-1)
Redim strNames(ImageCount-1)
namepos = 1
verpos = 1
blnLoaded = objXMLDocument.loadXML(strWimInformation)
k = 0
If (blnLoaded = True) And (objXMLDocument.parseError = 0) Then
For Each xNode In xNodes
objWIM.ImageIndex = k +1
namestart=InStr (namepos,strWimInformation,"<NAME>")
nameend=InStr (namepos,strWimInformation,"</NAME>")
strlen = nameend - namestart
strNames (k) = Mid(strWimInformation,namestart+6,strlen-6)
namepos = nameend + 1
strIndx(k) = xNode.getAttribute("INDEX")
k = k + 1
Next
End If
enumDirs
End sub
Hope this helps.
Also, I'm putting together a posting on my version and the correct way to have multiple wims with a menu.
Later,
dabone
#11
Posted 22 October 2009 - 11:41 AM
Now it appears everything is squared away for this HTA in 64bit.
#12
Posted 02 November 2009 - 10:34 AM
http://www.msfn.org/board/index.php?s=&...st&p=885860
Additional changes in order to re-build this HTA to 32bit for use on Atom and other 32-bit CPUs. Changes made:
- recompile all custom apps to ANSI instead of x64.
- replace the Gimagex_com.dll with the 32bit version.
- replace the SetRes exe instead of the 64bit resolution changer.
- Edit the Startnet.cmd with setres:
wpeinit wpeutil initializenetwork ping 127.0.0.1 -n 16 -w 1000 >null net use z: \\imagex\images Password1 /user:remote net use v: \\imagex\unattend regsvr32 /s misc/GImageX_COM.dll x:\windows\system32\misc\setres.exe 1024 600 32 60 mshta.exe x:\windows\system32\ImageX.hta
- replace all extra DLLs and EXE (from Windows 7 install) to 32bit versions.
I will be doing some testing with this version. The instructions should be the same as above, except make sure specify x86 instead of amd64 in the paths. Also not certain that the new background will work properly. I may have to change the colors in case the text does not appear properly.
Server 2008 x64 (or any x64 OS) as the Technician PC will give a message using DISM to import packages. The following Hotfix needs to be applied. Unfortunately the one for 2008 x64 does not appear in the "Request" page so I am going to have to get my elsewhere.
http://support.microsoft.com/kb/960037
#13
Posted 10 November 2009 - 01:03 PM
dabone, on Oct 15 2009, 03:24 PM, said:
I've been using it in house for awhile now.
This version runs under winpe 3.0 (x86 so far, I'll try X64 tomorrow)
The big changes I made to get it to run are.
The command window.confirm doesn't seem to work for me in pe 3.0 so they got replaced.
The xml for the wims are different, so I changed the way the program gets image names, the new way is much slower, but you can use it with new or old wims.
This version only support writing out images, giving a command shell, reboot, or shutdown. I made this for system builders to deploy images only.
If the Image description has the letters XP in it, the program will automatically put the nt52 bootsector on.
Hope this helps other people.
later,
dabone
Hi Friend, Could you post your code again please or can you sendme by email.
Thanks
#14
Posted 10 November 2009 - 02:36 PM
greenfrognet, on Nov 10 2009, 02:03 PM, said:
Thanks
The XML parser code change is here:
http://www.msfn.org/board/index.php?s=&...st&p=889162
The window.confirm code change examples are here:
http://www.msfn.org/...nd-not-working/
This post has been edited by Tripredacus: 22 April 2013 - 02:19 PM
Reason for edit: fixed link
#15
Posted 13 January 2010 - 02:34 AM

You have to go into misc, edit htastyle.css, and add "color: #FFFAFA" in the #title section, otherwise the default black text for the title is too hard to read (it's the color code for "snow").
#16
Posted 13 January 2010 - 08:31 AM
#17
Posted 15 January 2010 - 10:05 AM
1. adding this script to the head to resize/center the window is much faster than the existing method:
<script language="javascript"> var startWindowWidth = 1024; var startWindowHeight = 768; var startWindowLeft = 1; var startWindowTop = 1; window.moveTo(startWindowLeft, startWindowTop); window.resizeTo(startWindowWidth, startWindowHeight); </script>
2. The logic for checking window size doesn't work in some scenarios and you get offscreen windows if you use setres to resize a window from 800x600 to something larger (in my case, 1024x768) and have BORDER = none (which I do). Specifically, the map network drive and diskpart windows are almost completely off-screen - I've changed the logic as follows, since I know my screen is going to be 1024x768 for sure, I don't need to waste the time doing a lookup and can hard-code these:
'**************************************************************************** 'Network Drive mapper '**************************************************************************** ...<snip>... objFile1.WriteLine "Sub Window_Onload" objFile1.WriteLine " startWindowLeft = 312" objFile1.WriteLine " startWindowTop = 299" objFile1.WriteLine "" objFile1.WriteLine " window.moveTo startWindowLeft, startWindowTop" objFile1.WriteLine " window.resizeTo 400, 170" objFile1.WriteLine "End Sub"
'**************************************************************************** 'Diskpart '**************************************************************************** ...<snip>... ObjFile.WriteLine "Sub Window_Onload" objFile.WriteLine "On Error Resume next" objFile.WriteLine "objFso.DeleteFile(TempTXT1)" objFile.WriteLine "On Error Goto 0" objFile.WriteLine " startWindowLeft = 312" objFile.WriteLine " startWindowTop = 194" objFile.WriteLine "" objFile.WriteLine " window.moveTo startWindowLeft, startWindowTop" objFile.WriteLine " window.resizeTo 400, 380" ObjFile.WriteLine "custom.style.visibility = "&chr(34) & "hidden"&chr(34) & "" ObjFile.WriteLine "End Sub"
#18
Posted 17 February 2010 - 05:01 PM
thanks in advance
#19
Posted 17 February 2010 - 08:11 PM
This post has been edited by Sacriestory: 17 February 2010 - 11:06 PM
#20
Posted 18 February 2010 - 09:37 AM
Sacriestory, on 17 February 2010 - 08:11 PM, said:
There are a couple reasons why going to Win PE 3.0 is needed, but it depends on your need. You can still use the Win PE 2.x version if you want as long as you stay with the WAIK for Vista SP1. For me, once Windows 7 came out, we updated our Technician computers and Server with the OPK for Windows 7. The OPK is the OEM version of the WAIK, it is nearly the same except OPK gets different benefits depending on your partner level. Also, you need WinPE 3 to deploy Windows 7 or at least be able to get support on it from Microsoft.
I had found out early on that the Win7 OPK (and WAIK) cannot modify legacy WIMs, ie WIMs created with previous versions. So In order to making new updates and be able to put drivers in the image, we need to stay on the same version. If you do not have this requirement, you can just as easily use the Win PE 2.x version.
Quote
If you are using the 64bit WINPE you need the 64bit GImageX_COM.dll, download link is provided earlier in this thread.
- ← Win PE and other live media OSes as forensic tools
- Windows PE
- Modify Profile File and Generate a New Checksum →



Help

Back to top










