Jump to content

HTML Component Support in Vista PE


TofuBug

Recommended Posts

Everyone,

Quick question.

Has ANYONE gotten HTML Components to work in PE 2.0

I have HTA support turned on in the boot.wim along with scripting, mdac, xml, wmi

I am currently running a simple HTA for our imaging technicians that loads as part of PE (works great)

However most of the HTA tools I have developed for use in our normal operating environment are comprised of multiple HTML Components

One component for instance is Logon.htc

Nothing really fancy about it, when visible it provides the user a Username textbox and a Password textbox along with a logon button and Cancel button It has exposed methods to allow the component to be hidden or shown, it internally handles the actual Username and Password validation by bouncing off of AD using LDAP's OpenDSObject method finally it alerts its parent document of the success or failure of the logon attempt through 2 custom events onSuccessfulLogon and onUnsuccessfulLogon the Username and Password can be retrieved or changed using scripting for a userless interaction with the component as well

Here's logon.htc to give you an idea what I mean

<public:component lightWeight="True" tagname="Logon">
<public:method name="ShowLogon" />
<public:property name="UserID" get="GetUserID" put="PutUserID" />
<public:property name="Password" get="GetPassword" put="GetPassword" />
<Public:event name="onSuccessfullLogon" id="SuccessfullLogonEventID" />
<public:event name="onUnsuccessfullLogon" id="UnsuccessfullEventID" />
</public:component>
<script language="vbscript" type="text/vbscript">
On Error Resume Next
'----------------------Component HTML objects----------------------
Dim LogonTitleText
Dim UserNameText
Dim UserNameValueText
Dim PasswordText
Dim PasswordValueText
Dim OkButton
Dim CancelButton

'-----------------------Component "Constructor"-----------------------
Sub InitializeComponent()
Element.style.width = "192px"
Element.style.height = "94px"
Element.style.backgroundcolor = "menu"
Element.style.borderStyle = "outset"
Element.style.borderwidth = "thin"
Set LogonTitleText = Element.document.CreateElement("<input id=""LogonTitleText"" tabindex=""-1"" style=""font-weight: bold; font-size: 8pt; Left: 3px; width: 185px; border-top-style: none; font-family: verdana; border-Right-style: none; border-Left-style: none; position: absolute; top: 3px; text-decoration: underline; border-bottom-style: none; background-color: menu;"" type=""text"" value=""Logon (ACCT05 Credentials)"" readonly=""readOnly"" />")
Set UserNameText = Element.document.CreateElement("<input id=""UserNameText"" tabindex=""-1"" style=""font-size: 8pt; Left: 3px; width: 69px; border-top-style: none; font-family: verdana; border-Right-style: none; border-Left-style: none; position: absolute; top: 24px; border-bottom-style: none; background-color: menu;"" type=""text"" value=""User name:"" readonly=""readOnly"" />")
Set UserNameValueText = Element.document.CreateElement("<input id=""UserNameValueText"" tabindex=""999"" style=""font-size: 8pt; Left: 73px; width: 114px; font-family: verdana; position: absolute; top: 22px"" type=""text"" />")
Set PasswordText = Element.document.CreateElement("<input id=""PasswordText"" tabindex=""-1"" style=""font-size: 8pt; Left: 3px; width: 69px; border-top-style: none; font-family: verdana; border-Right-style: none; border-Left-style: none; position: absolute; top: 47px; border-bottom-style: none; background-color: menu;"" type=""text"" value=""Password:"" readonly=""readOnly"" />")
Set PasswordValueText = Element.document.CreateElement("<input id=""PasswordValueText"" tabindex=""1000"" style=""font-size: 8pt; Left: 73px; width: 114px; font-family: verdana; position: absolute; top: 45px"" type=""password"" />")
Set OkButton = Element.document.CreateElement("<input id=""OkButton"" tabindex=""1001"" style=""font-size: 8pt; Left: 3px; font-family: verdana; position: absolute; top: 68px; width: 60px;"" type=""button"" value=""OK"" />")
Set CancelButton = Element.document.CreateElement("<input id=""CancelButton"" tabindex=""1002"" style=""font-size: 8pt; Left: 127px; font-family: verdana; position: absolute; top: 68px"" type=""button"" value=""Cancel"" />")
Element.AppendChild(LogonTitleText)
Element.AppendChild(UserNameText)
Element.AppendChild(UserNameValueText)
Element.AppendChild(PasswordText)
Element.AppendChild(PasswordValueText)
Element.AppendChild(OkButton)
Element.AppendChild(CancelButton)
PasswordValueText.AttachEvent "onkeypress", GetRef("CheckKey")
UserNameValueText.AttachEvent "onkeypress", GetRef("CheckKey")
OkButton.AttachEvent "onclick", GetRef("TryLogon")
CancelButton.AttachEvent "onclick", GetRef("CancelLogon")
HideLogon()
End Sub

'-----------------------Internal Event Handlers-----------------------
Function ValidLogin(UserID,UserPassword)
On Error Resume Next
Set ValidLogin = GetObject("LDAP:").OpenDSObject("LDAP://<Domain Controller>/DC=<DC>,DC=com","<DC>\" + UserID,UserPassword,1 + 512)
ValidLogin = (Err.Number = 0)
End Function

Sub CheckKey() If window.event.keyCode = 13 Then TryLogon() : End If : End Sub

Sub TryLogon()
On Error Resume Next
If ValidLogin(UserNameValueText.Value,PasswordValueText.Value) Then
FireSuccessfullLogon()
Else
FailedLogon()
End If
HideLogon()
End Sub

Sub FailedLogon()
HideLogon()
FireUnsuccessfullLogon()
End Sub

Sub CancelLogon() : HideLogon() : End Sub

Function GetUserID() : GetUserID = UserNameValueText.value : End Function

Sub PutUserID(InUserID) : UserNameValueText.value = InUserID : End Sub

Function GetPassword() : GetPassword = PasswordValueText.value : End Function

Sub PutPassword(InPassword) : PasswordValueText.value = InPassword : End Sub
'---------------Exposed Methods---------------
Sub ShowLogon()
Element.style.display = ""
Element.setCapture()
If UserID = "" or IsEmpty(UserID) or IsNull(UserID) Then
UserNameValueText.value = ""
PasswordValueText.value = ""
UserNameValueText.Select()
Else
UserNameValueText.value = UserID
PasswordValueText.value = ""
PasswordValueText.Select()
End If
End Sub

'----------------Internal Methods----------------
Sub HideLogon()
Element.style.display = "none"
Element.ReleaseCapture()
End Sub

'--------------------Event Firing Methods--------------------
Sub FireSuccessfullLogon() : SuccessfullLogonEventID.Fire(Element.document.CreateEventObject()) : End Sub

Sub FireUnsuccessfullLogon() : UnsuccessfullEventID.Fire(Element.document.CreateEventObject()) : End Sub

InitializeComponent
</script>

Note: <Domain Controller> and <DC> have been changed so I don't get in trouble for divulging corporate domain information

Simple but very useful in any tool that requires sometimes alternate user credentials than the currently logged on user (I.E. Adding computers to Active Directory, Mapping Network Drives using alternate AD account info,...etc) by copying over the logon.htc to the tools source directory and adding very few lines of code, at most 2 lines of html and in no time at all what ever tool i'm developing has the ability to handle AD account validation.

In my eyes a major time saver and a major sanity saver.

You get the idea.

Well when I took the same working logon.htc file along with a test.hta file which referenced and utilize the Logon component and attempted to run it while under Vista PE the HTA crashes with errors like "TestLogon does not support .ShowLogon()"

I mapped over to my development network share from Vista PE and launched one of my working examples with the Logon component added and enabled would not work in PE (would work in XP or windows 2000)

I even tried to create a barebones htc with one <Public:Property /> tag and even it errors out in PE but works fine in normal windows.

This is really frustrating simply due to the fact I have been working hard and pushing process changes through to management to standardize and encapsulate our more commonly reused scripting tasks so I and the other developers don't have to keep rescripting the same old stuff over and over for every tool we are tasked with developing. but I digress

long and short I would like to get this working in Vista PE if that is possible

I would like to find out if there is some additional settings I need to change or build into the boot.wim to get HTC's to operate correctly in VistaPE

If anyone has any ideas or can point me in the direction of something more than just generic "how to deploy windows vista" FAQ’s I would greatly appreciate it.

Thanks in advance for any and all help

Cheers,

Ryan Strope

Distributed Services

(Software package development/testing)

Lockheed Martin Systems Integration Owego

(Cyber City Computers)

ryan.strope@lmco.com

Quid quid latine dictum sit, altum videtur

Link to comment
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.
×
×
  • Create New...