Help - Search - Members - Calendar
Full Version: WinPE 2.0 GimageX COM based HTA
MSFN Forums > Unattended Windows Discussion & Support > Windows PE
Pages: 1, 2, 3, 4, 5, 6

   
Google Internet Forums Unattended CD/DVD Guide
geezery
I have ported my HTA to support the GimageX COM Component which is also still in development.

Changelist:

- All available functions uses GImageX COM component
- No more those ugly Command Prompt windows (except diskpart)
- RebootAfterImageApply variable (When set i.e. 5 the computer reboots automaticly after image apply)
- Made the Browse function more efficient
- Image list scrollable
- Fixed several bugs in the diskpart function
- Removed the Start installing button (Installation of image starts when clicked the selected image)
- Mounting and Unmounting is disabled (You need to have imagex.exe if you want to enable those)

I know that there is still bugs in the script and I also want to add more features when they are available in the GimageX_COM. There is also an EULA.txt for the GimageX component so read it first. So reporting me the issues is very important.

Configuration:

Open Imagex.hta with your favourite text editor i.e. notepad.

cmdPartHD = "%comspec% /c diskpart /s misc\diskpart.txt" 'Location of the diskpart.txt file
myFilePath = "C:\" 'The folder that contains the *.wim files add "\" to the end of the path.
SetResSettings = "1024 768 32 1" 'Setres default parameters.

RebootAfterImageApply = 0 'Set the amount of seconds to wait for automatic reboot after applying an image.
'0 means that always prompt for shutdown.

EnableApplyCheck = "1" '0 = DISABLED 1 = ENABLED
EnableApplyVerify = "1" '0 = DISABLED 1 = ENABLED
EnableCaptureCheck = "1" '0 = DISABLED 1 = ENABLED
EnableCaptureVerify = "1" '0 = DISABLED 1 = ENABLED
EnableAppendCheck = "1" '0 = DISABLED 1 = ENABLED
EnableAppendVerify = "1" '0 = DISABLED 1 = ENABLED
CaptureCompressionLevel = "1" '0 = None 1 = Fast (default) 2 = Highest
AppendCompressionLevel = "1" '0 = None 1 = Fast (default) 2 = Highest

You also have to register the GImageX_COM.dll activex control before launching the ImageX.HTA. (regsvr32 /s misc/GImageX_COM.dll)

Currently there is no support for the progress indicator because I have not find a way how to use multithreaded COM object in HTA when running on WinPe v2. If you can find a way to show the progress indicator it would be more than nice.


Tested on real WinPe 2 cd-rom with these packages included

WinPE-HTA-Package
WinPE-MDAC-Package
WinPE-Scripting-Package
WinPE-XML-Package
WinPE-WMI-Package

If you have any questions, wishes or bug reports post here or send e-mail: geezery(at)gmail.com

Download the Zipped packages here:

New GimageX COM based version
COM Based v.0.71

Old ImageX.exe based Beta 4 v.0.70
http://www.filefactory.com/file/8e2166/

Click to view attachment
obiwantuxedo
Thanks for the HTA. This is exactly what I started last week. Yours, however, is an improvement over what I had started. I have added the Ghost32 capability for my techs to use should an ImageX image not be available. I am looking for a section that also allows for capture/append so we can create the ones we don't have. Any suggestions? I have started one that works in a separate HTA file, but when I add it to yours, it fails, only prompting for the first parameter (Drive to capture) the other two, WIM file name and description never appear. I'll post code tomorrow, left it at work.

Also, your link to the sample files isn't working.

Thanks again!
geezery
Thanks for your reply.

I fixed the broken link.

I didn't want to add those Capture / Append buttons, because I wanted to keep the menu simple as possible. And if I want to capture new image I can always use CMD-Prompt.

The description field might be nice, but I didn't have any use for more information about Images.

But if you are making some improvements to HTA, please post it here so everyone can use it. I look forward to see other versions of this HTA.
obiwantuxedo
Here's what I've got...
CODE
<!****************************************************************************>
<!* HTA Header >
<!****************************************************************************>
<HEAD>
<TITLE>ImageX Deployment</TITLE>
<HTA:APPLICATION
BORDER = yes
APPLICATION = Yes
WINDOWSTATE = MAXIMIZE
INNERBORDER = No
SHOWINTASKBAR = Yes
SCROLL = yes
APPLICATIONNAME = "Windows PE Wizard"
NAVIGABLE = Yes
>
<!-- external stylesheet -->
</HEAD>

<!****************************************************************************>
<!* Begin Script >
<!****************************************************************************>
&lt;script Language=VBScript>

'****************************************************************************
'* Globals
'* setup global script parameters
'****************************************************************************
Option Explicit
Dim strTaskValue, objShell, objFso, strBody, objWmiService, strImgSrc, strOutPut, cmdImgInfo, cmdPartHD, tmpFile, j, strImages, strLocation
Dim strIndx(), strNames()
Set objShell = CreateObject("WScript.Shell")
Set objFso = CreateObject("Scripting.FileSystemObject")
'Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")


'-------------- Editable commands --------------
' Diskpart command
cmdPartHD = "%comspec% /c diskpart /s z:\diskpart.txt"
' Image-X /info command. (xml-print)
cmdImgInfo= "%comspec% /c imagex /info z:\Image62.wim"
' Default file, where to parse image list
strImages = "z:\images.txt"
'------------------------------------------------
'****************************************************************************
'* Run Ghost is necessary
'****************************************************************************
Sub RunGhost32
Set objShell = CreateObject("Wscript.Shell")
objShell.Run ".\Ghost32.exe"
End Sub

'****************************************************************************
'* Window_OnLoad
'* load up behavior and preferences
'* Read image files
'* Parse indexes and filenames
'****************************************************************************
Sub Window_Onload
readImages()
strLocation = strImages 'InputBox("Path to images.txt file:", "images.txt" , strImages)
Call parseFile(strIndx, strNames, strLocation)
self.Focus()
strBody = "<BR><font face=verdana><B>Select image to apply:</B></font><BR>"
enumDirs
End Sub

'****************************************************************************
'* enumDirs
'****************************************************************************
Sub enumDirs
Dim colFilelist, objFile, strButtons, objShortcut, colTargetList, objTarget, x, y, strKey, strItem, k
ReDim arrButtons(1,-1)

'Reset display element style
details.innerHTML = ""
details.style.visibility = "hidden"

'Create list
For k = 0 To Ubound(strIndx)
ReDim Preserve arrButtons(1,UBound(arrButtons,2)+1)
arrButtons(0,UBound(arrButtons,2)) = strNames(k)
arrButtons(1,UBound(arrButtons,2)) = "<font face=verdana><Input type=radio name=radioList id='" & strIndx(k) & "' onClick=showRadioInfo>" & strNames(k) & "</font></BUTTON><BR>"
Next

'perform a a shell sort of the string array based on button label
For x = 0 To UBound(arrButtons,2) - 1
For y = x To UBound(arrButtons,2)
If StrComp(arrButtons(0,x),arrButtons(0,y),vbTextCompare) > 0 Then
strKey = arrButtons(0,x)
strItem = arrButtons(1,x)
arrButtons(0,x) = arrButtons(0,y)
arrButtons(1,x) = arrButtons(1,y)
arrButtons(0,y) = strKey
arrButtons(1,y) = strItem
End If
Next
Next

'End of the list
For x = 0 To UBound(arrButtons,2)
strButtons = strButtons & "<tr><td id=buttonTd>" & arrButtons(1,x) & "</td></tr>"
Next

strBody = strBody & "<BR><HR><BR>"
strBody = strBody & strButtons & "<BR><HR><BR><button class='defBtn' id=start Accesskey=S onclick=doTask(strTaskValue)><U>A</U>pply</BUTTON>   <Button class = 'defBtn' id=close onclick=self.close()> Close </BUTTON>"

body.innerHTML = strBody
End Sub

'****************************************************************************
'* doTask
'* run task selected by radio button
'****************************************************************************
Sub doTask(doMe)
Dim myInput
Dim myError
If doMe = "" Then
MsgBox "You must choose image to apply first."
Else
If Instr(1, doMe, "gex /apply", 1) > 0 Then
myInput = MsgBox("The hard disk of the computer will be formatted and the image will be applied to it."+Chr(13)+Chr(13)+"Continue?", 4)
If myInput = 7 Then
MsgBox "Aborted by user"
Else
doTask(cmdPartHD)
objShell.Run doMe
End if
Else
myError = objShell.Run(doMe, 1, True)
End if
End if
End Sub

'****************************************************************************
'* readImages
'* Imagex info-print -> file
'****************************************************************************
Sub readImages()
'ObjShell.Run "%comspec% /c Dir " & chr(34) & strImgSrc & chr(34) & " > " & chr(34) & strOutPut & chr(34)
' Imagex /Info command
' ObjShell.Run "%comspec% /c " & cmdImgInfo & " > " & chr(34) & strOutPut & chr(34)
' objShell.Run cmdImgInfo & " > " & strImages
End Sub

'****************************************************************************
'* parseFile
'* Parses the text inside <name> and <index> tags from text file.
'****************************************************************************
Sub parseFile(strIndx(), strNames(), strFile)
Dim objTextFile, sReadLine, pos, pos2, i, tmpStr1
i = -1
Redim strNames(0)
Redim strIndx(0)

If objFso.FileExists(strFile) Then
Set objTextFile = objFso.OpenTextFile(strFile, 1)
Do While Not objTextFile.AtEndOfStream
sReadLine = objTextFile.ReadLine
' indexit ja name haltuun
pos2 = Instr(1, sReadLine, "<IMAGE", 1)
pos = Instr(1, sReadLine, "<NAME>", 1)
If pos2 > 0 Then
i = i + 1
Redim Preserve strIndx(i)
Redim Preserve strNames(i)
'strIndx(i) = Right(sReadLine, Len(sReadLine) - (pos2 + 9))
tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos2 + 13))
strIndx(i) = Left(tmpStr1, Len(tmpStr1) -2)
End If

If pos > 0 Then
'strNames(i) = Right(sReadLine, Len(sReadLine) - (pos + 5))
tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos + 5))
strNames(i) = Left(tmpStr1, Len(tmpStr1) -8)
End If
loop
End If
End sub
'****************************************************************************
'* showRadioInfo
'****************************************************************************
Sub showRadioInfo
Dim objTextFile, Radio, strRadioValue, strDetails
'set details and start element styles
details.style.visibility = "visible"
start.style.visibility = "visible"
'find checked button
For Each Radio in Document.getElementsByName("radioList")
If Radio.Checked = True Then
'create imaging command line from button id
strTaskValue = "imagex /apply z:\Image62.wim " + Radio.Id + " c:"
End If
Next
'post resulting html to details element
Details.innerHTML = "<BR><font face=verdana><table id='detailsTable'><tr><td>" & strDetails & "</td></tr></table></font><BR>"
End Sub
'****************************************************************************
'* Reset'* reset the tool interface, also reloads the code (helpful for programming)
'****************************************************************************


</Script>
<!****************************************************************************>
<!* End Script / Begin HTML >
<!****************************************************************************>

'<BODY background="pe.jpg">
<table width=739 height =128 background=./masthead.jpg><tr><td align=center valign=bottom><font face=verdana color=white><b>ImageX Deployment Menu</b></font></td></tr></table>
<DIV id=bg>
<!-- <img src="K:\WinPE\pe.jpg"> -->

</DIV>

<DIV id=body></DIV>
<DIV id=details></DIV>

<DIV id=tools>


</DIV>
<br>
<table border="0" width="737">
<tr>
<td bgcolor="#000000" >
<p align="center"><font face="Verdana" color="#FFFFFF"><b>
Symantec Ghost</b></font></td>
</tr>


<tr>
<td ><font face="Verdana" size="2">If all else fails, you can use Ghost to image a workstation. 
You will need to know the path to the image or call the Help Desk (x4-5666) to setup a Multicast session.</td>
</tr>


<tr>
<td> </td>
</tr>
<tr>
<td><font face="Verdana" size="2"><font face = Verdana>

<input id=runbutton3 class="button" type="button" value="Ghost32" name="btnGhost32" onClick="RunGhost32"></font></td>
</tr>
</table>

</BODY>
</HTML>

<!****************************************************************************>
<!* End HTML >
<!****************************************************************************>


So far the response from my techs and other SAs has been great. Again, thanks.
obiwantuxedo
Here is the code I added for the capture, but only gives me one prompt instead of the the three:

Under the &lt;script ...>
CODE
'****************************************************************************
'* Capture Image
'****************************************************************************
Sub RunScript
strDrv = window.prompt("Please enter the drive letter you would like to capture.", "Drive Letter")
strWimFile = window.prompt("Please enter the name for the captured image.", "Image Name")
strWimDesc = window.prompt("Please enter the make and model, i.e. Dell Latitude D820.", "Description")

'Test purposes only!!!
Msgbox "IMAGEX /CAPTURE "& strDrv &" " & strDrv & "\"& strWimFile & " " &chr(34) & strWimDesc &chr(34) & " /verify /compress maximum"

End Sub


Under <BODY ...>
CODE
<input id="runbutton" class="button" type="button" value="Capture" name="run_button" onClick="RunScript">


Like I said before, when I run this exact code in an HTA of its' own, it works. Cut and paste into this HTA, and I only receive one prompt.
geezery
Good to hear some nice feedback.

I personally wouldnt use that /compress maximum switch, because the time it takes is like 3x to normal compression and the size difference is quite small.

And you don't need that verify switch, if you are using network path, because it is turned on by default on network paths.

Very nice work obionetuxedo.

If someone else has some more ideas to give, put your wishes here.
zorphnog
While I agree that compress max takes a substantially greater amount of time to capture, the difference in size can be great depending on what kind of data you're capturing. Compression algorithms rely on repeated data, so if you have a lot of similar data it can make a difference. In my captures it reduces the size by about 25% which is fairly good considering I have 9GB images. Though for smaller images its not very beneficial.
Seattle
Hello,

First, I would like to say thanks to the OP for some fine work here smile.gif

Second, I am trying to use this in my PE Boot Image (WDS Server) and it sort-of works.

PE Loads / Boots / Initializes / Maps the Drive / and then launches the program but I receive a script error.

Error:

Line: 54
Char: 1
Error: Invalid Syntax
Code: 0

It asks if I would like to continue running the script and I click yes.

The interface comes up with no images listed.

If you need more information, please let me know.

Thanks!
geezery
I think you have problem with the images.txt file.

Can you post your code here?
Seattle
QUOTE (geezery @ May 10 2007, 09:56 AM) *
I think you have problem with the images.txt file.

Can you post your code here?


CODE
<html>
<!--
'********************************************************************
'*
'* File: ImageXHTA.hta
'* Author: geezery
'* Big thanks to : greg & fisher
'* Created: May 2007
'* Version: .1
'*
'* Description: windows imaging platform
'*
'* Dependencies: tested on and for WinPE 2.0 with WMI, Scripting,
'* XML, HTA packages, Imagex components
'* Notes: Line 28 - might want to make this "normal" when you are
'* testing and don't want the hta fullscreen
'* Line 206 - Put your background image there if you want
'********************************************************************
-->

<!****************************************************************************>
<!* HTA Header >
<!****************************************************************************>
<HEAD>
<TITLE>Imaging Application</TITLE>
<HTA:APPLICATION
BORDER = yes
APPLICATION = Yes
WINDOWSTATE = maximize
INNERBORDER = No
SHOWINTASKBAR = Yes
SCROLL = No
APPLICATIONNAME = "Windows PE Wizard"
NAVIGABLE = Yes
>
<!-- external stylesheet -->
<link rel="stylesheet" type="text/css" href="htastyle.css" />
</HEAD>

<!****************************************************************************>
<!* Begin Script >
<!****************************************************************************>
&lt;script Language=VBScript>

'****************************************************************************
'* Globals
'* setup global script parameters
'****************************************************************************
Option Explicit
Dim strTaskValue, objShell, objFso, strBody, objWmiService, strImgSrc, strOutPut, cmdImgInfo, cmdPartHD, tmpFile, j, strImages, strLocation
Dim strIndx(), strNames()
Set objShell = CreateObject("WScript.Shell")
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")


'-------------- Editable commands --------------
' Diskpart command
cmdPartHD = "%comspec% /c diskpart /s F:\winpe\diskpart.txt"
' Image-X /info command. (xml-print)
cmdImgInfo= "%comspec% /c imagex /info F:\images.wim"
' Default file, where to parse image list
strImages = "F:\Winpe\images.txt"
'------------------------------------------------

'****************************************************************************
'* Window_OnLoad
'* load up behavior and preferences
'* Read image files
'* Parse indexes and filenames
'****************************************************************************
Sub Window_Onload
readImages()
strLocation = InputBox("Path to images.txt file:", "images.txt" , strImages)
Call parseFile(strIndx, strNames, strLocation)
self.Focus()
strBody = "<div id='title'>Tetra Tech Deployment Center</div>" & "<BR><B>Select image to apply:</B><BR>"
enumDirs
End Sub

'****************************************************************************
'* enumDirs
'****************************************************************************
Sub enumDirs
Dim colFilelist, objFile, strButtons, objShortcut, colTargetList, objTarget, x, y, strKey, strItem, k
ReDim arrButtons(1,-1)

'Reset display element style
details.innerHTML = ""
details.style.visibility = "hidden"

'Create list
For k = 0 To Ubound(strIndx)
ReDim Preserve arrButtons(1,UBound(arrButtons,2)+1)
arrButtons(0,UBound(arrButtons,2)) = strNames(k)
arrButtons(1,UBound(arrButtons,2)) = "<Input type=radio name=radioList id='" & strIndx(k) & "' onClick=showRadioInfo>" & strNames(k) & "</BUTTON><BR>"
Next

'perform a a shell sort of the string array based on button label
For x = 0 To UBound(arrButtons,2) - 1
For y = x To UBound(arrButtons,2)
If StrComp(arrButtons(0,x),arrButtons(0,y),vbTextCompare) > 0 Then
strKey = arrButtons(0,x)
strItem = arrButtons(1,x)
arrButtons(0,x) = arrButtons(0,y)
arrButtons(1,x) = arrButtons(1,y)
arrButtons(0,y) = strKey
arrButtons(1,y) = strItem
End If
Next
Next

'End of the list
For x = 0 To UBound(arrButtons,2)
strButtons = strButtons & "<tr><td id=buttonTd>" & arrButtons(1,x) & "</td></tr>"
Next

strBody = strBody & "<BR><HR><BR>"
strBody = strBody & strButtons & "<BR><HR><BR><button class='defBtn' id=start Accesskey=S onclick=doTask(strTaskValue)><U>A</U>pply image</BUTTON><BR>"

body.innerHTML = strBody
End Sub

'****************************************************************************
'* doTask
'* run task selected by radio button
'****************************************************************************
Sub doTask(doMe)
Dim myInput
Dim myError
If doMe = "" Then
    MsgBox "You must choose image to apply first."
Else
    If Instr(1, doMe, "gex /apply", 1) > 0 Then
        myInput = MsgBox("The hard disk of the computer will be formatted and the image will be applied to it."+Chr(13)+Chr(13)+"Continue?", 4)
        If myInput = 7 Then
            MsgBox "Aborted by user"    
        Else
            doTask(cmdPartHD)    
            objShell.Run doMe
        End if
    Else
        myError = objShell.Run(doMe, 1, True)
    End if
End if
End Sub

'****************************************************************************
'* readImages
'* Imagex info-print -> file
'****************************************************************************
Sub readImages()
    'ObjShell.Run "%comspec% /c Dir " & chr(34) & strImgSrc & chr(34) & " > " & chr(34) & strOutPut & chr(34)
    ' Imagex /Info command
    ' ObjShell.Run "%comspec% /c Dir " & cmdImgInfo & " > " & chr(34) & strOutPut & chr(34)
End Sub

'****************************************************************************
'* parseFile
'* Parses the text inside <name> and <index> tags from text file.
'****************************************************************************
Sub parseFile(strIndx(), strNames(), strFile)
Dim objTextFile, sReadLine, pos, pos2, i, tmpStr1
i = -1
Redim strNames(0)
Redim strIndx(0)

If objFso.FileExists(strFile) Then
    Set objTextFile = objFso.OpenTextFile(strFile, 1)
    Do While Not objTextFile.AtEndOfStream
        sReadLine = objTextFile.ReadLine
        ' indexit ja name haltuun
        pos2 = Instr(1, sReadLine, "<IMAGE", 1)
        pos = Instr(1, sReadLine, "<NAME>", 1)
        If pos2 > 0 Then
            i = i + 1
            Redim Preserve strIndx(i)
            Redim Preserve strNames(i)
            'strIndx(i) = Right(sReadLine, Len(sReadLine) - (pos2 + 9))
            tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos2 + 13))
            strIndx(i) = Left(tmpStr1, Len(tmpStr1) -2)
        End If

        If pos > 0 Then
            'strNames(i) = Right(sReadLine, Len(sReadLine) - (pos + 5))
            tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos + 5))
            strNames(i) = Left(tmpStr1, Len(tmpStr1) -8)
        End If
    loop
End If
End sub
'****************************************************************************
'* showRadioInfo
'****************************************************************************
Sub showRadioInfo
Dim objTextFile, Radio, strRadioValue, strDetails
'set details and start element styles
details.style.visibility = "visible"
start.style.visibility = "visible"
'find checked button
For Each Radio in Document.getElementsByName("radioList")
If Radio.Checked = True Then
'create imaging command line from button id
strTaskValue = "imagex /apply F:\images.wim " + Radio.Id + " c:"
End If
Next
'post resulting html to details element
Details.innerHTML = "<BR><table id='detailsTable'><tr><td>" & strDetails & "</td></tr></table><BR>"
End Sub

'****************************************************************************
'* Reset
'* reset the tool interface, also reloads the code (helpful for programming)
'****************************************************************************
Sub Reset
Location.Reload(True)
End Sub

</Script>
<!****************************************************************************>
<!* End Script / Begin HTML >
<!****************************************************************************>

'<BODY background="pe.jpg">
<DIV id=bg>
<!-- <img src="pe.jpg"> -->

</DIV>

<DIV id=body></DIV>
<DIV id=details></DIV>

<DIV id=tools>
<Button class = 'defBtn' id=cmd onclick=doTask('%comspec%')> CMD-Prompt </BUTTON>
<Button class = 'defBtn' id=close onclick=self.close()> Close </BUTTON>
<Button class = 'defBtn' id=reset onclick=reset> Refresh List</BUTTON>
</DIV>
</BODY>
</HTML>

<!****************************************************************************>
<!* End HTML >
<!****************************************************************************>


** Also, are these files supposed to be placed on the MappedDrive:\winpe\ folder? I keep getting an access denied when calling the HTA, even though the drive maps fine.

I apologize for my newbiness smile.gif I really do appreciate your help.

Originally, I added these files to the winpe boot image and was able to call the HTA but that is when I receive the script error.

Then I saw the note about creating a winpe folder in the image directory but now i am receiving access denied. sad.gif
geezery
I think you have an file access problem.

Here is how I use this HTA:

1. Make a Windows share somewhere for example \\mysrv\share

2. Give the appropriate access to files & share it for "Everyone".
(You can test it by giving user "Everyone" Read access to share)

3. Put your *.wim file & diskpart.txt file to that dir.
(Then you must create an xml output file from your wim file)

4. You can do it from cmd prompt easily (imagex /info filename.wim > images.txt)
(Now you have three files inside the share "images.wim, images.txt, diskpart.txt")

5. You should also edit diskpart.txt to suite in your needs.

6. Put ImageXHTA.hta and htastyle.css in your boot.wim system32 folder. That way you can call the hta file without full pathname.
(You can also put all these files in the network share and call those mshta.exe Z:\ImageXHTA.hta) (Z:\ mapped network path)
(I haven't tested this method, but it would be great, because you could edit the hta file afterwards.)

You can also put several wim files in the share and make multiple xml output files. Then just point to the xml file you want. You can also leave this section blank if you want always to specify correct path to xml output file.

CODE
' Default file, where to parse image list
strImages = "F:\Winpe\images.txt"
p4ntb0y
Very Nice!

If I wanted append images within images will this still have the same effect?
I am a bit of a vbs noob and still going thru it.


It be nice to have all my image options from the xml file (again I have to research weather you can get /info from appeded images)

then select the one I require and off it goes with the right append number.

I would then look to split this across two cds and deploy to our engineers as a backup for no network, be great for support.
geezery
Of course it works. The example images.wim file has three images here in my sample. I don't know about the splitting to cd's.
p4ntb0y
next time I finish reading thru your code and not just jump in at the deep end sorry for that.
thebearpoo
Thanks for the source code. I need some help though, I am getting an error message after my diskpart runs and exits.
Error is -
Line: 140
Char: 4
Error: The system cannot find the specified file.
Code: 0
URL: file:////X:/windows/system32/tools/hta/ImageXHTA.hta


diskpart.txt, install.wim, and images.txt are all located in a network drive that is mapped using the net use command before the ImageXHTA.hta apps is launched in WINPE 2.0. ImageXHTA.hta, htasyle.css, pe.jpg, and Update Image list.cmd are located in the windows\system32\tools\hta folder of the boot.wim file.

Here is my code:

CODE
<html>
<!--
'********************************************************************
'*
'* File: ImageXHTA.hta
'* Author: geezery
'* Big thanks to : greg & fisher
'* Created: May 2007
'* Version: .1
'*
'* Description: windows imaging platform
'*
'* Dependencies: tested on and for WinPE 2.0 with WMI, Scripting,
'* XML, HTA packages, Imagex components
'* Notes: Line 28 - might want to make this "normal" when you are
'* testing and don't want the hta fullscreen
'* Line 206 - Put your background image there if you want
'********************************************************************
-->

<!****************************************************************************>
<!* HTA Header >
<!****************************************************************************>
<HEAD>
<TITLE>Imaging Application</TITLE>
<HTA:APPLICATION
BORDER = yes
APPLICATION = Yes
WINDOWSTATE = maximize
INNERBORDER = No
SHOWINTASKBAR = Yes
SCROLL = No
APPLICATIONNAME = "Windows PE Wizard"
NAVIGABLE = Yes
>
<!-- external stylesheet -->
<link rel="stylesheet" type="text/css" href="htastyle.css" />
</HEAD>

<!****************************************************************************>
<!* Begin Script >
<!****************************************************************************>
&lt;script Language=VBScript>

'****************************************************************************
'* Globals
'* setup global script parameters
'****************************************************************************
Option Explicit
Dim strTaskValue, objShell, objFso, strBody, objWmiService, strImgSrc, strOutPut, cmdImgInfo, cmdPartHD, tmpFile, j, strImages, strLocation
Dim strIndx(), strNames()
Set objShell = CreateObject("WScript.Shell")
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")


'-------------- Editable commands --------------
' Diskpart command
cmdPartHD = "%comspec% /c diskpart /s Q:\diskpart.txt"
' Image-X /info command. (xml-print)
cmdImgInfo= "%comspec% /c imagex /info Q:\install.wim"
' Default file, where to parse image list
strImages = "Q:\images.txt"
'------------------------------------------------

'****************************************************************************
'* Window_OnLoad
'* load up behavior and preferences
'* Read image files
'* Parse indexes and filenames
'****************************************************************************
Sub Window_Onload
readImages()
strLocation = InputBox("Path to images.txt file:", "images.txt" , strImages)
Call parseFile(strIndx, strNames, strLocation)
self.Focus()
strBody = "<div id='title'>ImageX Deployment platform</div>" & "<BR><B>Select image to apply:</B><BR>"
enumDirs
End Sub

'****************************************************************************
'* enumDirs
'****************************************************************************
Sub enumDirs
Dim colFilelist, objFile, strButtons, objShortcut, colTargetList, objTarget, x, y, strKey, strItem, k
ReDim arrButtons(1,-1)

'Reset display element style
details.innerHTML = ""
details.style.visibility = "hidden"

'Create list
For k = 0 To Ubound(strIndx)
ReDim Preserve arrButtons(1,UBound(arrButtons,2)+1)
arrButtons(0,UBound(arrButtons,2)) = strNames(k)
arrButtons(1,UBound(arrButtons,2)) = "<Input type=radio name=radioList id='" & strIndx(k) & "' onClick=showRadioInfo>" & strNames(k) & "</BUTTON><BR>"
Next

'perform a a shell sort of the string array based on button label
For x = 0 To UBound(arrButtons,2) - 1
For y = x To UBound(arrButtons,2)
If StrComp(arrButtons(0,x),arrButtons(0,y),vbTextCompare) > 0 Then
strKey = arrButtons(0,x)
strItem = arrButtons(1,x)
arrButtons(0,x) = arrButtons(0,y)
arrButtons(1,x) = arrButtons(1,y)
arrButtons(0,y) = strKey
arrButtons(1,y) = strItem
End If
Next
Next

'End of the list
For x = 0 To UBound(arrButtons,2)
strButtons = strButtons & "<tr><td id=buttonTd>" & arrButtons(1,x) & "</td></tr>"
Next

strBody = strBody & "<BR><HR><BR>"
strBody = strBody & strButtons & "<BR><HR><BR><button class='defBtn' id=start Accesskey=S onclick=doTask(strTaskValue)><U>A</U>pply image</BUTTON><BR>"

body.innerHTML = strBody
End Sub

'****************************************************************************
'* doTask
'* run task selected by radio button
'****************************************************************************
Sub doTask(doMe)
Dim myInput
Dim myError
If doMe = "" Then
MsgBox "You must choose image to apply first."
Else
If Instr(1, doMe, "gex /apply", 1) > 0 Then
myInput = MsgBox("The hard disk of the computer will be formatted and the image will be applied to it."+Chr(13)+Chr(13)+"Continue?", 4)
If myInput = 7 Then
MsgBox "Aborted by user"
Else
doTask(cmdPartHD)
objShell.Run doMe
End if
Else
myError = objShell.Run(doMe, 1, True)
End if
End if
End Sub

'****************************************************************************
'* readImages
'* Imagex info-print -> file
'****************************************************************************
Sub readImages()
'ObjShell.Run "%comspec% /c Dir " & chr(34) & strImgSrc & chr(34) & " > " & chr(34) & strOutPut & chr(34)
' Imagex /Info command
' ObjShell.Run "%comspec% /c Dir " & cmdImgInfo & " > " & chr(34) & strOutPut & chr(34)
End Sub

'****************************************************************************
'* parseFile
'* Parses the text inside <name> and <index> tags from text file.
'****************************************************************************
Sub parseFile(strIndx(), strNames(), strFile)
Dim objTextFile, sReadLine, pos, pos2, i, tmpStr1
i = -1
Redim strNames(0)
Redim strIndx(0)

If objFso.FileExists(strFile) Then
Set objTextFile = objFso.OpenTextFile(strFile, 1)
Do While Not objTextFile.AtEndOfStream
sReadLine = objTextFile.ReadLine
' indexit ja name haltuun
pos2 = Instr(1, sReadLine, "<IMAGE", 1)
pos = Instr(1, sReadLine, "<NAME>", 1)
If pos2 > 0 Then
i = i + 1
Redim Preserve strIndx(i)
Redim Preserve strNames(i)
'strIndx(i) = Right(sReadLine, Len(sReadLine) - (pos2 + 9))
tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos2 + 13))
strIndx(i) = Left(tmpStr1, Len(tmpStr1) -2)
End If

If pos > 0 Then
'strNames(i) = Right(sReadLine, Len(sReadLine) - (pos + 5))
tmpStr1 = Right(sReadLine, Len(sReadLine) - (pos + 5))
strNames(i) = Left(tmpStr1, Len(tmpStr1) -8)
End If
loop
End If
End sub
'****************************************************************************
'* showRadioInfo
'****************************************************************************
Sub showRadioInfo
Dim objTextFile, Radio, strRadioValue, strDetails
'set details and start element styles
details.style.visibility = "visible"
start.style.visibility = "visible"
'find checked button
For Each Radio in Document.getElementsByName("radioList")
If Radio.Checked = True Then
'create imaging command line from button id
strTaskValue = "imagex /apply Q:\install.wim " + Radio.Id + " c:"
End If
Next
'post resulting html to details element
Details.innerHTML = "<BR><table id='detailsTable'><tr><td>" & strDetails & "</td></tr></table><BR>"
End Sub

'****************************************************************************
'* Reset
'* reset the tool interface, also reloads the code (helpful for programming)
'****************************************************************************
Sub Reset
Location.Reload(True)
End Sub

</Script>
<!****************************************************************************>
<!* End Script / Begin HTML >
<!****************************************************************************>

<BODY background="pe.jpg">
<DIV id=bg>
<!-- <img src="pe.jpg"> -->

</DIV>

<DIV id=body></DIV>
<DIV id=details></DIV>

<DIV id=tools>
<Button class = 'defBtn' id=cmd onclick=doTask('%comspec%')> CMD-Prompt </BUTTON>
<Button class = 'defBtn' id=close onclick=self.close()> Close </BUTTON>
<Button class = 'defBtn' id=reset onclick=reset> Refresh List</BUTTON>
</DIV>
</BODY>
</HTML>

<!****************************************************************************>
<!* End HTML >
<!****************************************************************************>


Here is my images.txt file
CODE


ImageX Tool for Windows

Copyright © Microsoft Corp. 1981-2005. All rights reserved.





WIM Information:
----------------
GUID: {1bf6a4c6-35cf-45a4-be1a-526c70946546}
Image Count: 1
Compression: XPRESS
Part Number: 1/1
Attributes: 0xc
Integrity info
Relative path junction


Available Image Choices:
------------------------
<WIM>

<TOTALBYTES>2029827781</TOTALBYTES>

<IMAGE INDEX="1">

<NAME>Windows Vista Business</NAME>

<FLAGS>Business</FLAGS>

<WINDOWS>

<ARCH>0</ARCH>

<PRODUCTNAME>Microsoft® Windows® Operating System</PRODUCTNAME>

<HAL>acpiapic</HAL>

<PRODUCTTYPE>WinNT</PRODUCTTYPE>

<PRODUCTSUITE>Terminal Server</PRODUCTSUITE>

<LANGUAGES>

<LANGUAGE>en-US</LANGUAGE>

<DEFAULT>en-US</DEFAULT>

</LANGUAGES>

<VERSION>

<MAJOR>6</MAJOR>

<MINOR>0</MINOR>

<BUILD>6000</BUILD>

<SPBUILD>16386</SPBUILD>

</VERSION>

<SYSTEMROOT>WINDOWS</SYSTEMROOT>

</WINDOWS>

<DIRCOUNT>6845</DIRCOUNT>

<FILECOUNT>38059</FILECOUNT>

<TOTALBYTES>7416098786</TOTALBYTES>

<CREATIONTIME>

<HIGHPART>0x01C79672</HIGHPART>

<LOWPART>0x475F3C78</LOWPART>

</CREATIONTIME>

<LASTMODIFICATIONTIME>

<HIGHPART>0x01C79672</HIGHPART>

<LOWPART>0x48083E5F</LOWPART>

</LASTMODIFICATIONTIME>

</IMAGE>

</WIM>



Any ideas???
thebearpoo
Problem solved!!!!!!!!!

Make sure to have your WINPE 2.0 base installation correct first, especially copying imagex.exe into the \mount\windows folder structure.
frankenstein897
Forgive my ignorance but, when you reference images.wim does that contain multiple images in 1 file? I have multiple wim files for each images, am I doing that wrong? I am new to imagex so please forgive me. I am trying to figure out how to get this script to enumerate all of the images but, if you are supposed to put it in 1 file then that would make a different. Sorry, confused

Thanks,
Chris
eth0
QUOTE (frankenstein897 @ May 25 2007, 04:38 PM) *
I have multiple wim files for each images, am I doing that wrong? I am new to imagex so please forgive me. I am trying to figure out how to get this script to enumerate all of the images but, if you are supposed to put it in 1 file then that would make a difference.

It's not wrong, but you lose one of the advantages the WIM format has i.e. specify multiple versions in the same file.
You can check the (revised) imagex documentation http://www.microsoft.com/downloads/details...;displaylang=en for the details if you want.

I think the hardest part would be getting your script to list the internal catalogue and echo that back into your HTA/textfile/whatever.
I dunno, maybe a dynamic array or something "could" solve that.
geezery
I think I'm going to add support for multiple *.wim files in the hard coded folder. Maybe it can be dynamic also. I have to change the code a lot.

If someone has example for me to get the imagex /info wimfile.wim output to variable I could make that easily.

There is a nice component available, but it is not free. ****

http://www.smartdeploy.com/products/index.htm
frankenstein897
Ok, I am convinced to use one image file. Pretty sweet. Thanks all!
geezery
OK, I have found a way to get imagex /info wimfile.wim to variable

CODE
Dim oShell, oExec
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("imagex.exe /info D:\Waik\F1_WINPE.wim")
ImgInfo = oExec.StdOut.ReadAll
WScript.echo  ImgInfo
kl300zx
HI
I follow all your step the HTA when the windows pe boot up, the network map auto map to drive I:\
then the ImageXHTA.HTA fiel launch but is unable to connect to the images.txt on the share drive, when I get to I:\dir /w/p I see the Images.txt. and check all access right is good. is there any thing in the ImageXHTA.HTA Script I need to edit to make this work, when I test this in the Windows and is work fine.
Please help
Thank you
Kevin
geezery
If it works on Windows for you, then it should work also in PE.

You can always open CMD-Prompt in PE and try to go to the I:\ share.

The refresh button also checks the images.txt file again, if you want to refresh it.
pretender69
any chance you have this in zip format ?
my coding skills suck tongue.gif

TIA


QUOTE (obiwantuxedo @ May 8 2007, 01:37 PM) *
Here is the code I added for the capture, but only gives me one prompt instead of the the three:

Under the &lt;script ...>
CODE
'****************************************************************************
'* Capture Image
'****************************************************************************
Sub RunScript
strDrv = window.prompt("Please enter the drive letter you would like to capture.", "Drive Letter")
strWimFile = window.prompt("Please enter the name for the captured image.", "Image Name")
strWimDesc = window.prompt("Please enter the make and model, i.e. Dell Latitude D820.", "Description")

'Test purposes only!!!
Msgbox "IMAGEX /CAPTURE "& strDrv &" " & strDrv & "\"& strWimFile & " " &chr(34) & strWimDesc &chr(34) & " /verify /compress maximum"

End Sub


Under <BODY ...>
CODE
<input id="runbutton" class="button" type="button" value="Capture" name="run_button" onClick="RunScript">


Like I said before, when I run this exact code in an HTA of its' own, it works. Cut and paste into this HTA, and I only receive one prompt.
kl300zx
hi qeezy
I download this and follow everythin in your instruction, but this is my problem.
I create a share drive on the network and put images.txt and dispart.txt with 2007.wim on the share.
I copy the imagexhta.hta and htastype.css to the system32 folder on the winpe boot disk. I create a net use command in the startnet, so the it will auto map for me. the loading good , map network drive good, but when I launch the imagexhta.hta the is only come up with no menu, basicly is load but is won't read tyhe imagex.txt file I think. I check all the map and check for perimssion is all good. I wonder any where I need to look for this problem.
THank you very much for this, and is will be cool if I can get this work.
Thank you
geezery
Hello everyone reading my thread.

I have spent the whole weekend designing the next release of this.

I have made some nice changes in the script.

-No more those static images.txt files
-Dynamic drop down list of the image files (ability to have many images in the shared folder)
-Capture and Append options


It's almost ready, I have to clean the script a lot and make some error checking. I try to release it tomorrow.

I think this can be useful also for those who only want to drop their "vanilla" sysprepped images from cd or dvd. I have to also make new instructions for this.

BTW: there is a link on the first post to zipped version, but I wouldn't bother using it, since the next rel. will be totally better
p4ntb0y
I be looking forward to it!!

Sounds great

many thanks
kl300zx
Cool
thank you so much,
I got the otherone working but only for one image, this new one will be so cool.
thank you
pretender69
nice to here smile.gif
will be watching for it tomorrow smile.gif

thx
geezery
Look at the first post.
pretender69
sweet thumbup.gif
will give it a test later this evening.

Thank you smile.gif
ccb458
I was checking out your version 1 file yesterday and couldn't get it to work. Thank you so much for the new v2 files. I tried it out, and it seems great. However, I can't get it to deploy the image after DiskPart. Looking at your hta file, I found that you have hardcoded i:\images.wim in the following line:

strTaskValue = "imagex /apply i:\images.wim " + Radio.Id + " c:"


I don't know if that's the cause of problem asI am not familar with scripting language, could you help checking it?

Thanks..
geezery
I must fix some problems. Fixed version coming soon.
ccb458
I have modified the code (add a few lines) in the "ShowRadioInfo" section. It seems to work, maybe you could check it out and see if it needs further modification.

geezery, I am trying to add a button to reboot the computer, but I don't know how to pass the "wpeutil reboot" thru your doTask, could you give me some ideas?


thx
-----




CODE
'****************************************************************************
'* showRadioInfo
'* display details of radio button selection in details divider
'****************************************************************************
Sub showRadioInfo
Dim objTextFile, Radio, strRadioValue, strDetails, objSel1, strFile

Set objSel1 = window.document.getElementById("select1")
strFile = myFilePath + objSel1.options(objSel1.selectedindex).text

details.style.visibility = "visible"
start.style.visibility = "visible"
For Each Radio in Document.getElementsByName("radioList")
If Radio.Checked = True Then
strTaskValue = "imagex /apply " + strFile + " " + Radio.Id + " c:"
End If
Next
Details.innerHTML = "<BR><table id='detailsTable'><tr><td>" & strDetails & "</td></tr></table><BR>"
End Sub
geezery
Maybe you can put exit on the lastline of the startnet.cmd

startnet.cmd

wpeinit
net use command
ImageXHTAv2.hta
exit

Then just put the put the window.close on the script.

I didn't test this method, but I think it should work, because the startnet.cmd stops when the ImageXHTAv2.hta is running, and it continues after it is closed.

I have already fixed all the errors and put some addons also. I will post the new zip soon.
geezery
V0.21

Fixed some major bugs and added also possibility to use the Wims "Description" field.
pretender69
wow 0.21 already, will do some tests with 0.21 when i get home,

was wondering if you could add ability to skip diskpart.txt settings, and maybe just a option to say 'format c: /fs:ntfs /q /y'
or format 'drive letter' /fs:ntfs /q /y

also is it possible to add ability to use ghost as well as imagex ?

btw thx for the great work you are doing on this project. smile.gif


P.S. was just looking at the imagexhta file in 0.21 and some parts aren't in english ?
geezery
QUOTE (pretender69 @ May 30 2007, 06:39 PM) *
wow 0.21 already, will do some tests with 0.21 when i get home,

was wondering if you could add ability to skip diskpart.txt settings, and maybe just a option to say 'format c: /fs:ntfs /q /y'
or format 'drive letter' /fs:ntfs /q /y

also is it possible to add ability to use ghost as well as imagex ?

btw thx for the great work you are doing on this project. smile.gif


P.S. was just looking at the imagexhta file in 0.21 and some parts aren't in english ?



You can use diskpart to do the format c:\ for you, I assume you have only one disk.

diskpart.txt

select disk 0
select partition 1
format fs=ntfs label="system" quick
active
exit


There is already a Ghost HTA available, search the Winpe Section on this forum.

You can of course add a button here to start ghost32.exe

Make this sub

CODE
'*****************************************************************************
'Ghost32
'****************************************************************************
Sub Ghost32    
Set objShell = CreateObject("Wscript.Shell")    
objShell.Run "Ghost32.exe" 'You have to put the necessery ghost files to WinPE path variable i. e. Windows\System32
End Sub


Then you must add the button to HTA:

[code]
<Button class = 'btn' id=capture onclick=Ghost32()> Ghost32 </Button>
[code]

I don't think that there is a point to make ghosting commands here, because there is so much of them.
pretender69
actually i have 5 drives
and have already added the ghost32 smile.gif
works great using both smile.gif

think i can just comment out the diskpart from running before deployin the image and format from the cmd prompt.

hopefully it work will test it out. smile.gif

how about a option for choosing what compression to use for capture ?

thx for all your hard work smile.gif
p4ntb0y
A option to include a format if its required would be nice maybe just a tick box.

I can put this in but would be nice to be in your script as this would help loads of people that are not to good at scripting.

An option to split across cd's would be nice (Only joking I still looking into this and really what to use your script when I work it out)

again many thanks for this! it's people like yourself that really help other people out.
p4ntb0y
You may want to have a look at this autoit script...

Autoit Script GUI for Imagex

this works ok but I like your one more as I can actually follow it at least.
solutionone
Hi Geezery, I have to say you're doing some truely amazing work here. I was originally trying to make my own solution using crappy old batch files and while googling discovered this thread and the rest of the brilliant team at MSFN.

I was wondering if there is anyway you can modify the HTA so when started it pops up a window asking for the location of the wim files instead of hard coding it in the hta.

at the moment I use a external usb hard drives to store my wim files, and its letter changes alot depending on partitions/optical drives etc. on each PC so being able to pick the wim source when starting the hta would be a huge improvement .

Also may I suggest that when a capture is to be ran, a simple chkdsk /f should be run precedding the capture as imagex is prone to failing a capture halfway through if there are errors on the drive.

once again thanks for all your great work, and let me know if you need any testing done, as I have a pretty good lab at our workshop.
ccb458
Geezzry,

Thanks for your new version v21. I tried it out, but for unknown reasons, the process still stops after DISKPART.. I am still using your v2 files, and adding the Reboot option by calling a .cmd batch file.

thx..
geezery
QUOTE
ccb458 ->

The v2 is very buggy, you should download the new version asap.


QUOTE
Solutionone ->

I can add the popup to ask for the location of the wim files in the next release. I'm mainly using new computers for this and I haven't get the apply failure yet. Maybe I can add that feature when I also got some failures:)

Testing is very important and I hope that if someone find bugs, please notify me. I don't have much time for testing in real environment.


QUOTE
p4antb0y ->

Actually I tried that Autoit script some while ago, but it was so buggy and I didn't like the design at all.


If someone want's to help me with this project. I have one request. Nice background would be great, since I don't have any skills to make a nice one by my self. Of course it should be freely distributed so any commercial material is not allowed.
ccb458
geezery,

I already did download your new version (v.2.1), but don't know why it stops after diskpart. That's the reason I go back to v.2. What happened on my environment is after diskpart windows disappeared, nothing else happened.

thx
geezery
I think I found an error in the script.

On ParseFile Sub

Change this line

strIndx(i) = Left(tmpStr1, Len(tmpStr1) -2)

To this

strIndx(i) = Left(tmpStr1, Len(tmpStr1) -3)

Can you test it?
ccb458
geezery,

I changed I changed that line, but it seems the same, i.e. after diskpart, the process finished without applying the image..
p4ntb0y
Geezery,

for the background how about the vista one with an option of adding your own company logo (like oem.bmp) then anyone can add their own in you could even add a support button with info and docs.
p4ntb0y
geezery,

just testing your script out it would be really really handy to have a browse dropdown list for the capture and append buttons.
geezery
QUOTE (ccb458 @ May 31 2007, 01:09 PM) *
geezery,

I changed I changed that line, but it seems the same, i.e. after diskpart, the process finished without applying the image..


Can someone else test the apply, because I don't have test environment here at work?

p4antb0y ->

Like I said the picture should be non commercial freely distributed. I think that vista background can't be freely added to this package.

I didn't undestand that dropdown system. Can you describe it better?
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.