IPB

Google Frontpage Forums Unattended CD/DVD Guide
 Forum Rules Unattended CD/DVD Guide Homepage · MSFN Forum Rules
5 Pages V   1 2 3 > »   
Reply to this topicStart new topic
> WinPE 2.0 simple Ghost Menu HTA, a simple HTA to make Ghosting easy
keythom
post Mar 30 2007, 02:19 PM
Post #1





Group: Members
Posts: 5
Joined: 26-October 05
Member No.: 77846
Country Flag


Most of the WinPE help seems to tend toward advanced plug-ins to create a live cd desktop.
I like that too, but my main need at work is maintaining a simple and easy imaging platform for technicians.

If anyone is looking for something like that, here is my first stab at a solution.
Some features:
  • dynamically creates image options from directory structure = easy updating, no editing WinPE image
  • displays a separate details panel for each image for in-depth image info, version history, notes, etc
  • relies on a basic WinPE 2.0 image with only stock add-ins = easy to build and maintain


To begin, you'll need a working WinPE 2.0 with WMI, Scripting, XML, HTA packages installed.
Networking needs to be functional also.

There is a ton of help on this site and others for getting that far.
I really recommend the PXE or RIS/WDS bootable WIM setup.

Add a line in the startnet.cmd to create a mapped drive to your image location, example:
net use z: \\server\imageShare

In the image share location, create a new directory for the imaging HTA to use, example:
z:\winpe
This path is hardcoded into the HTA and you may need to change it for your situation, see notes in HTA itslef.

Referring to the screencap above and using the example mapped drive z:, here is a description of how things should work:
  • category buttons (Dell WS, HP WS,...) are generated from subdirectory names in z:\winpe
  • shortcut links in category subdirs point to image targets
  • radio button entries are created from shortcut links in each category subdir
  • radio button names are created from description field of shortcut
  • details for each image are linked from an .htm file with the same name as the .gho target
When creating shortcut links, be sure to use the mapped drive path instead of a unc path.

The quick and easy way I have made the details files is saving from Excel as .htm. Name it the same as a .gho and it should display, sometimes takes a little experimenting to make it look right. An obvious upgrade would be to use a nice spreadsheet control or something, but I took the simple way.

We'll be using ImageX for more images pretty soon and this interface should be easy to adapt for that also because the buttons are only command lines actually.

Hope this can help some people. I'm no web designer or code engineer, so there is a lot to be improved but it is meeting our needs currently.

Thank you,
Fisher


if you like the backgound in there, here it is:
http://i171.photobucket.com/albums/u290/keythom/pe.jpg

Here is the HTA code:
CODE
<html>
<!--
'********************************************************************
'*
'* File: wizard.hta
'* Author: greg & fisher
'* Created: Mar 2007
'* Modified:
'* Version: .9
'*
'* Description: windows imaging platform
'*
'* Dependencies: tested on and for WinPE 2.0 with WMI, Scripting,
'* XML, HTA packages
'* Notes: Line 26 - might want to make this "normal" when you are
'* testing and don't want the hta fullscreen
'* Line 58 - customize your headings here
'* Line 72, 101 - confirm directory.name path, this would be a mapped
'* drive to the filer where the images shorcut dir is
'* Line 193 - confirm background image source location
'* Line 200 - confirm path to ghost executable
'*
'********************************************************************
-->

<!****************************************************************************>
<!* HTA Header >
<!****************************************************************************>
<HEAD>
<TITLE>Imaging Application</TITLE>
<HTA:APPLICATION
BORDER = None
APPLICATION = Yes
WINDOWSTATE = normal
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
Set objShell = CreateObject("WScript.Shell")
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject ("winmgmts:\\.\root\cimv2")

'****************************************************************************
'* Window_OnLoad
'* load up behavior and preferences
'****************************************************************************
Sub Window_Onload
self.Focus()
strBody = "<H1>PE Build and Recovery Environment</H1>" &_
"<H2>Select Images to apply an OS image using Ghost.<BR><BR>" &_
"Please select an image category:<BR><BR>"
enumDirs
End Sub

'****************************************************************************
'* enumDirs
'* find directories and create category buttons
'****************************************************************************
Sub enumDirs
Dim colSubfolders, objFolder, fileName
'enumerate folders in images folder
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='z:\winpe'} Where AssocClass = Win32_Subdirectory ResultRole = PartComponent")
'create html buttons from each folder name
For Each objFolder in colSubfolders
fileName = objFolder.fileName
strBody = strBody &_
"<button id='" & fileName & "' onClick='enumImages("" & fileName & "")'>" & fileName & "</BUTTON>"
Next
'post resulting html body to document
strBody = strBody & "<BR><HR><BR>"
body.innerHTML = strBody
End Sub

'****************************************************************************
'* enumImages
'* find images and create radio buttons
'****************************************************************************
'this sub is a little messy because of limitations of win32_shortcutfile and need to go between fso and wmi for different info
'also, without the advantages of .net sorting classes, the old bubble sorting is not the funnest

Sub enumImages(fileName)
Dim colFilelist, objFile, strButtons, objShortcut, colTargetList, objTarget, x, y, strKey, strItem
ReDim arrButtons(1,-1)

'reset display element style
details.innerHTML = ""
details.style.visibility = "hidden"
' strButtons = "<table id=buttonTable>"
'enumerate ghost image shortcuts in specific images subfolder from enumDirs
Set colFileList = objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_Directory.Name='z:\winpe\" & fileName & "'} Where ResultClass = CIM_DataFile")
'find ghost image shortcut targetpath (fso)
For each objFile in colFileList
If objFile.Extension = "lnk" Then
Set objShortcut = objShell.CreateShortcut(objFile.name)
'find ghost image shortcut target (wmi)
Set colTargetList = objWMIService.ExecQuery _
("Select * from CIM_Datafile Where name = '" & replace(objShortcut.targetpath,"\","\\") & "'")
'add radio button label (from fso) and radio button target (from wmi) to an array
For each objTarget in colTargetList
ReDim Preserve arrButtons(1,UBound(arrButtons,2)+1)
arrButtons(0,UBound(arrButtons,2)) = objShortcut.Description
arrButtons(1,UBound(arrButtons,2)) = "<Input type=radio name=radioList id='" & objTarget.Drive & objTarget.Path &

objTarget.fileName &_
"' onClick=showRadioInfo>" & objShortcut.Description & "</BUTTON><BR>"
Next
End If
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
'create combined buttons html code from sorted buttons array
For x = 0 To UBound(arrButtons,2)
strButtons = strButtons & "<tr><td id=buttonTd>" & arrButtons(1,x) & "</td></tr>"
Next
' strButtons = strButtons & "</table>"
'create a start button with start image command and append and post resulting html to body
body.innerHTML = strBody & strButtons & "<BR><HR><BR><button id=start Accesskey=S onclick=doTask(strTaskValue)><U>S</U>tart

Image!</BUTTON><BR>"
start.style.visibility="hidden"
End Sub

'****************************************************************************
'* doTask
'* run task selected by radio button
'****************************************************************************
Sub doTask(doMe)
objShell.Run doMe
End Sub

'****************************************************************************
'* showRadioInfo
'* display details of radio button selection in details divider
'****************************************************************************
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 = Chr(34) & "%programfiles%\ghost8\ghost32.exe" & Chr(34) & " -clone,mode=restore,src=" & Chr(34) &

Radio.Id & ".gho" & Chr(34) & ",dst=1"
'display image details in details element if they exist
If objFso.FileExists(Radio.Id & ".htm") Then
Set objTextFile = objFso.OpenTextFile(Radio.Id & ".htm", 1)
strDetails = objTextFile.ReadAll()
Else
'display error message in details element if no matching details file found
strDetails = "Can't find anything!!!<BR><BR>" &_
"Make sure the info file has the same name as the .gho and has an .htm extension."
End If
End If
Next
'post resulting html to details element
Details.innerHTML = strDetails
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>
<DIV id=bg>
<img src=winpe.bmp>
</DIV>

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

<DIV id=tools>
<Button id=ghost onclick=doTask('"%programfiles%\ghost8\ghost32.exe"')>Ghost</BUTTON>
<Button id=cmd onclick=doTask('%comspec%')> Cmd </BUTTON>
<Button id=notepad onclick=doTask('notepad')> Notepad </BUTTON>
<Button id=taskmgr onclick=doTask('taskmgr')> Taskmgr </BUTTON>
<Button id=close onclick=self.close()> Quit </BUTTON>
<Button id=reset onclick=reset> ResetApp </BUTTON>
<Button id=reboot onclick=self.navigate('reboot.hta')> Reboot </BUTTON>
</DIV>
</BODY>
</HTML>

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


This post has been edited by keythom: Mar 30 2007, 05:36 PM
Attached File(s)
Attached File  wizard.hta.txt ( 9.72K ) Number of downloads: 3360
Attached File  htaStyle.css ( 2.02K ) Number of downloads: 2082
Attached File  reboot.hta.txt ( 605bytes ) Number of downloads: 1791
 
Go to the top of the page
 
+Quote Post
p4ntb0y
post Mar 30 2007, 05:00 PM
Post #2


Member
**

Group: Members
Posts: 237
Joined: 14-February 06
Member No.: 87996
Country Flag


Nice this should help some people out.

What about adding an option for images to be on a USB Drive weather they ghost or wim. This will cope with situations where you have no network conectivity an engineer could boot an UFD and load the image by USB disc

can't beleive 18 views and not one thanks!
Go to the top of the page
 
+Quote Post
Jazkal
post Mar 30 2007, 07:08 PM
Post #3


Senior Member
****

Group: Members
Posts: 564
Joined: 16-January 04
From: Texas
Member No.: 12605
Country Flag


Very nice, thanks for sharing.
Go to the top of the page
 
+Quote Post
Br4tt3
post Apr 2 2007, 12:14 AM
Post #4


World famous sausage eater...
****

Group: Members
Posts: 566
Joined: 20-April 04
From: Malmö
Member No.: 18221
Country Flag


Hi keythom!

Awsome first two posts.... love the work, thanks for sharing.
Go to the top of the page
 
+Quote Post
Stratuscaster
post Apr 5 2007, 01:04 PM
Post #5


Newbie


Group: Members
Posts: 31
Joined: 5-April 07
Member No.: 134295
Country Flag


This is a good start, as I've been looking for something similar.

I'm unclear on where the files you provided would actually go, however. And the "z:\winpe" structure is a little hazy to me as well. Perhaps a screenshot of the explorer tree would help?

I think it's:

z:\winpe
z:\winpe\dell
z:\winpe\dell\image1.lnk
z:\winpe\dell\image1.htm
z:\winpe\dell\image2.lnk
z:\winpe\dell\image2.htm

Is that correct? And the images themselves can be elsewhere as defined by the shortcuts, yes?
Go to the top of the page
 
+Quote Post
jinkyjinx
post Apr 10 2007, 08:21 PM
Post #6





Group: Members
Posts: 4
Joined: 1-September 06
Member No.: 109225
Country Flag


Very nice thanks for the post much appreciated
Go to the top of the page
 
+Quote Post
geezery
post Apr 11 2007, 11:23 PM
Post #7


Member
**

Group: Members
Posts: 249
Joined: 21-July 06
From: Helsinki
Member No.: 105112
Country Flag


It would be nice to have something similar to this made for imagex.
Go to the top of the page
 
+Quote Post
keythom
post Apr 13 2007, 07:03 PM
Post #8





Group: Members
Posts: 5
Joined: 26-October 05
Member No.: 77846
Country Flag


Here's an embarrassing attempt at a graphic explanation if it helps any.
I'm sorry for any harm to your eyes.

Please let me know if you try this and if you have any trouble, I'll try to help.

For the imaging to launch, you'll need to put the ghost files into \program files\ghost8\ or set the location in the HTA. There is a comment at the top with the line number for that.

I'll update when I have some imageX incorporated.

For testing I map the drive to the ghost images location as it is set in our PE image and launch the HTA on my normal workstation. I did work for a long time using some .NET classes and was very disappointed when I ran it on WinPE though.

have a great weekend!
Fisher

Go to the top of the page
 
+Quote Post
Stratuscaster
post Apr 14 2007, 09:24 AM
Post #9


Newbie


Group: Members
Posts: 31
Joined: 5-April 07
Member No.: 134295
Country Flag


That helps clear things up a bit.

When I attempt to run the wizard.hta, I'm getting "Access is denied."
Go to the top of the page
 
+Quote Post
keythom
post Apr 16 2007, 11:12 AM
Post #10





Group: Members
Posts: 5
Joined: 26-October 05
Member No.: 77846
Country Flag


In WinPE 2.0, I get the Access Denied error when starting an HTA from a non-system drive like a mapped drive or removable media device.
Try launching the HTA from a location on the system drive, should be X:.
Go to the top of the page
 
+Quote Post
wikky80
post Apr 21 2007, 10:58 AM
Post #11





Group: Members
Posts: 1
Joined: 6-March 05
Member No.: 46570
Country Flag


thumbup.gif Well done My Dear !
Go to the top of the page
 
+Quote Post
tombtek99
post Apr 30 2007, 09:23 PM
Post #12





Group: Members
Posts: 1
Joined: 30-April 07
Member No.: 137625
OS: none
Country Flag


Great Stuff!! I am working on something similar. A couple things I added which might be helpful to some folks.
We have about 8 locations and customizing the paths for each of them was a pain. So I called an IPCONFIG > x:\ipconfig.txt in startnet.cmd. I used a read in the txt file to map the drive based on the dns suffix (or you could use ipaddress ranges, etc). That made sure the mapping to Z:\ was consistent.
In the fat vs thin image arguement, we chose to go with 2 very, very thin xp images (Apic & Pic) with extensive post image scripting for machine specific customizations (laptop/desktop/workstation, Lenovo/HP, SP/MP, Raid/NonRaid, IDE/Sata, etc). I used the machine type wmi script from the bdd (2.0) to idenify the machine type as a text file. I put a hook on the end of my imagex.bat to call copy.vbs which copies all of the machine specific software and drivers based on x:\machinetype.txt[to the local PC before it reboots and starts sysprep. I have a call in my sysprep that launches the drivers and software installs.
We use a modified wizard.hta from December's technet in our WinPE and the net result is a KISS boot disc that is location and machine independent. The tech just clicks a button to image the machine either up, down, or up and down, and walks away until the XP mini-setup. Three screens there and then give it 5-15 mins (desktop vs laptop) and the unit is ready for data migration. We can't use accounts in sysprep (to automate the mini setup) and I don't think our users (read engineers) will be ready for automated data migration any time soon, so that is a far as we can go with automating our process.
Hope this helps.
Go to the top of the page
 
+Quote Post
Stratuscaster
post May 1 2007, 02:01 PM
Post #13


Newbie


Group: Members
Posts: 31
Joined: 5-April 07
Member No.: 134295
Country Flag


QUOTE (keythom @ Apr 16 2007, 12:12 PM) *
In WinPE 2.0, I get the Access Denied error when starting an HTA from a non-system drive like a mapped drive or removable media device.
Try launching the HTA from a location on the system drive, should be X:.

No dice - still get "Access is denied" when launching from x:\ghosthta - perhaps if I knew where you placed the HTA files?
Go to the top of the page
 
+Quote Post
Jazkal
post May 1 2007, 02:05 PM
Post #14


Senior Member
****

Group: Members
Posts: 564
Joined: 16-January 04
From: Texas
Member No.: 12605
Country Flag


I launch all my HTA's via network share (mapped drives), that way I can update them without having to rebuild my WinPE Images.

In WinPE2 I use the following to call my HTA files:

cmd.exe /c Mshta.exe z:\PATH\FILENAME.hta

This post has been edited by Jazkal: May 1 2007, 02:05 PM
Go to the top of the page
 
+Quote Post
zorphnog
post May 2 2007, 07:15 AM
Post #15


Advanced Member
***

Group: Members
Posts: 427
Joined: 25-July 06
From: Charleston, SC
Member No.: 105938
Country Flag


I've found that for some reason you always have to specify the full path of the file for mshta to execute properly. So even if you are in the folder where the .hta file is located, you still have to type the full path.

CODE
X:\Windows\System32>mshta.exe X:\Windows\System32\wizard.hta
Go to the top of the page
 
+Quote Post
dbensing
post May 3 2007, 09:13 AM
Post #16





Group: Members
Posts: 1
Joined: 1-May 07
Member No.: 137683
OS: Vista Business x86
Country Flag


First of all - Thanks for all the great info in this thread...


I have created a Booting USB flash drive with a nice little Boot Environement. I am currently setting this up for a Ghost environment, but will probably be switching over to an ImageX environment in the future. I can get this to boot and work on my Dell D610s, Optiplex 280s, etc with no issue. It will not work on my D600s. The whole thing loads, but I get a script error when it trys to populate the Image lists. It is because it doesn;t load the network drivers right. It should work with the B57win32.inf driver like the other Dells that work, but it doesn't. I have tried putting my own drivers into the PE Image, but it doesn't seem to work. The 610, and 280 are using what appears to be an existing B57 driver in the PE environment. I guess the 600 doesn't like it (I saw all this from looking at the PE Boot Log and seeing what drivers load). Here is what my build scriptslook like:

pushd "C:\Program Files\Windows AIK\Tools\PETools\"

if not exist "c:\winpe_x86" (

rem Prepare the build environment

call copype.cmd x86 "c:\winpe_x86"

rem Copy the Windows PE source files from the image to the build environment

md c:\winpe_x86\base
imagex /apply "C:\Program Files\Windows AIK\Tools\PETools\x86\winpe.wim" 1 c:\winpe_x86\base

rem Set TimeZone

peimg /timezone="Eastern Standard Time" c:\winpe_x86\base

rem Install optional components in to the image

peimg /install=WinPE-HTA-Package c:\winpe_x86\base
peimg /install=WinPE-Scripting-Package c:\winpe_x86\base
peimg /install=WinPE-XML-Package c:\winpe_x86\base
peimg /install=WinPE-WMI-Package c:\winpe_x86\base

rem Install Applications

xcopy /chery c:\Apps\imagex.exe "c:\winpe_x86\base\program files\imagex\imagex.exe"
xcopy /chery c:\Apps\ghost32.exe "c:\winpe_x86\base\program files\ghost\ghost32.exe"

rem Copy Custom startnet.cmd

xcopy /chery c:\CMDFiles\startnet.cmd "c:\winpe_x86\base\windows\system32\startnet.cmd"

rem Copy Custom Environment Files

xcopy /chery c:\Apps\WSCwizard.hta "c:\winpe_x86\base\WSCwizard.hta"
xcopy /chery c:\Apps\pe.jpg "c:\winpe_x86\base\pe.jpg"
xcopy /chery c:\Apps\htaStyle.css "c:\winpe_x86\base\htaStyle.css"
xcopy /chery c:\Apps\reboot.hta "c:\winpe_x86\base\reboot.hta"

rem Install device drivers in to the image

peimg /inf=c:\drivers\*.inf c:\winpe_x86\base\Windows

)

popd

Then I run another script to Prep and finish it up:

pushd "C:\Program Files\Windows AIK\Tools\PETools\"

rem Prepare the image for capture by optimizing it

peimg /prep c:\winpe_x86\base /f

rem Capture the image

"c:\Program Files\Windows AIK\Tools\x86\imagex.exe" /boot /compress max /capture c:\winpe_x86\base c:\winpe_x86\ISO\sources\boot.wim "WSC Windows PE"

popd

Any ideas? I know about Mounting and applying the Drivers, then Unmounting, but that didn't do anything for me either... I am using the Vista Resource Kit as reference here. Just out of things to try and could use some help.

Thanks,
Darren
Go to the top of the page
 
+Quote Post
pretender69
post May 10 2007, 09:13 AM
Post #17


Junior
*

Group: Members
Posts: 76
Joined: 29-June 06
Member No.: 100158
Country Flag


anyone happen to have this in zip format?

TIA smile.gif
Go to the top of the page
 
+Quote Post
Bumbastik
post Jun 8 2007, 09:03 AM
Post #18


Newbie


Group: Members
Posts: 25
Joined: 31-October 05
Member No.: 78286
Country Flag


keythom,

please, can you post your htm file about this great tutorial


Thanks
Bumbastik
Go to the top of the page
 
+Quote Post
idanlerer
post Jun 28 2007, 02:44 AM
Post #19





Group: Members
Posts: 4
Joined: 27-June 07
Member No.: 144618
OS: none
Country Flag


Thanks for your sharing.
I have one Q about this.

While I preper the HTA it's look good on my computer but when it run on the Windows PE, it's not open in full screen of the win PE and I'm getting line breaking.
Any idea why ?
Go to the top of the page
 
+Quote Post
Bumbastik
post Jun 28 2007, 06:59 AM
Post #20


Newbie


Group: Members
Posts: 25
Joined: 31-October 05
Member No.: 78286
Country Flag


Hi ,

change in hta code this parameters

from

WINDOWSTATE = normal


to
WINDOWSTATE = fullscreen


bye
Go to the top of the page
 
+Quote Post

Google Frontpage Forums Unattended CD/DVD Guide

5 Pages V   1 2 3 > » 
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 




Lo-Fi Version Time is now: 21st November 2009 - 11:27 PM
All trademarks mentioned on this page are the property of their respective owners
MSFN is not affiliated with Microsoft
Copyright © 2001-2009 msfn.org
Privacy Policy