• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
geezery

WinPE 2.0 GimageX COM based HTA

357 posts in this topic

Not available anymore

The software is available again, but in a non-support/community project basis.

The original author has abandoned this project, so I am taking over its sponsorship. I cannot take any requests for adding or updating new features to the software.

UPDATE

1. Version 9.0 and 9.1 are not stable, more testing needs to be done.

2. Currently testing v7.1 in WinPE 3.0 x64

3. Merged both threads.

Last available versions

Version 7.1 :: download

Version 9.0 :: download

Custom PE backgrounds

Embedded by Tripredacus :: download

Vista by Tripredacus :: download

Edited by Tripredacus
0

Share this post


Link to post
Share on other sites

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!

Edited by obiwantuxedo
0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

Here's what I've got...

<!****************************************************************************>
<!* 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 >
<!****************************************************************************>
<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.

0

Share this post


Link to post
Share on other sites

Here is the code I added for the capture, but only gives me one prompt instead of the the three:

Under the <script ...>

'****************************************************************************
'* 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 ...>

<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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

Hello,

First, I would like to say thanks to the OP for some fine work here :)

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!

0

Share this post


Link to post
Share on other sites

I think you have problem with the images.txt file.

Can you post your code here?

0

Share this post


Link to post
Share on other sites
I think you have problem with the images.txt file.

Can you post your code here?

<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 >
<!****************************************************************************>
<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 :) 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. :(

Edited by Seattle
0

Share this post


Link to post
Share on other sites

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.

' Default file, where to parse image list
strImages = "F:\Winpe\images.txt"

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

next time I finish reading thru your code and not just jump in at the deep end sorry for that.

0

Share this post


Link to post
Share on other sites

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:

<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 >
<!****************************************************************************>
<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



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???

0

Share this post


Link to post
Share on other sites

Problem solved!!!!!!!!!

Make sure to have your WINPE 2.0 base installation correct first, especially copying imagex.exe into the \mount\windows folder structure.

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites
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.

0

Share this post


Link to post
Share on other sites

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

Edited by geezery
0

Share this post


Link to post
Share on other sites

OK, I have found a way to get imagex /info wimfile.wim to variable

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

Edited by geezery
0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

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.

0

Share this post


Link to post
Share on other sites

any chance you have this in zip format ?

my coding skills suck :P

TIA

Here is the code I added for the capture, but only gives me one prompt instead of the the three:

Under the <script ...>

'****************************************************************************
'* 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 ...>

<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.

0

Share this post


Link to post
Share on other sites

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

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.