Jump to content


  • 0
Rob MacLennan

HTA Help

Question

Guys firstly I must apologise but I'm having great problems with these HTAs.

 

My environment is SCCM 2007 R3, Deploying OSD using Task Sequence for Win 7.

 

I'm trying to following this guide from the Deployment Guys (here)

 

I have had a few problems:

 

1. HTA not showing up, MININT screen was appearing until I found the guide on here to turn off.

 

2. HTA appears, appears to contact DB but the TS takes over and carries on building.

 

Whilst the guides on here are good I'm still having problems, is there, other than on here, any videos, guides and or line by line guides? I know this is probably the most easiest of tasks and I'm probably reading too much into it but pressure is on and would appreciate any further help if available.

 

Q's

 

When I'm uploading the HTA files where should they be and should they follow any special type of structure

 

Is there a manual way of testing these HTAs before going through the whole process of pxe over and over...

 

more to follow....

 

R

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

first of all why do you want to use a HTA what is your goal ?

secondly to speed up testing of the hta rather than have it in the boot image you can add it to the task sequence itself, that means that you only need to update the package the hta is part of (usually mdt files) rather than update the boot image as with the example you linked to

Share this post


Link to post
Share on other sites

  • 0

Hi

 

Thanks for the reply.

 

I want the HTA so that the machine can be configured to its location as they may not be built onsite. As you'll see from the link it will confirm the IP and loaction by using an MDT lookup for the default gateway.

 

In short to allow the engineer building the PC to confirm its name, select its location (there are 30) and finally and this is the bit I want to discover is to populate into the correct OU without any interaction.

 

Robert

Share this post


Link to post
Share on other sites

  • 0

One quick tidbit... To quickly test HTAs... Boot up WinPE on a PC, and then map a network drive to a folder containing your code. You make edits on your normal machine and then just fire them off via Command Line under WinPE. No need to update images and build new boot media or anything.

 

What do you mean when you say select its location?

 

We've got a fairly complex HTA in our environment (which needs cleaned up, but that's another story), so here are some randomish chunks of code that might help you get where you're going. If you have questions, let me know and I (and others of course) can try to help when I have a little more time...

 

 

' ~$~----------------------------------------~$~

Sub BindToActiveDirectory

'Attemping to connect to the AD environment using LDAP with alternate credentials

ReadRegistryForAD

'Editing the HKCU 1406 registry keys to avoid any ADO Security Warning message windows

objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\0\1406", 0, "REG_DWORD"

objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1406", 0, "REG_DWORD"

objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2\1406", 0, "REG_DWORD"

objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1406", 0, "REG_DWORD"

Log ("Attemping to bind to Active Directory using LDAP with alternate credentials")

Set objNS = GetObject("LDAP:")

'Attempting to obtain the LDAP information")

Set objRootDSE = objNS.OpenDSObject("LDAP://" & strDomainControllerFQDN & "/RootDSE", strAccountUserName, strAccountPassword, ADS_SERVER_BIND Or ADS_SECURE_AUTHENTICATION)

strDNSDomain = objRootDSE.Get("defaultNamingContext")

'Attempting to use ADO to search Active Directory

Set adoCommand = CreateObject("ADODB.Command")

Set adoConnection = CreateObject("ADODB.Connection")

adoConnection.Provider = "ADsDSOObject"

adoConnection.Properties("User ID") = strAccountUserName

adoConnection.Properties("Password") = strAccountPassword

adoConnection.Properties("Encrypt Password") = True

adoConnection.Properties("ADSI Flag") = ADS_SERVER_BIND Or ADS_SECURE_AUTHENTICATION

adoConnection.Open "Active Directory Provider"

'Replacing the original HKCU 1406 registry key information

If Not strRegistryKey0 = "" Then

objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1406", strRegistryKey0, "REG_DWORD"

End If

If Not strRegistryKey1 = "" Then

objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1406", strRegistryKey1, "REG_DWORD"

End If

If Not strRegistryKey2 = "" Then

objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1406", strRegistryKey2, "REG_DWORD"

End If

If Not strRegistryKey3 = "" Then

objWshShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1406", strRegistryKey3, "REG_DWORD"

End If

adoCommand.ActiveConnection = adoConnection

adoCommand.Properties("Page Size") = 100

adoCommand.Properties("Timeout") = 30

adoCommand.Properties("Cache Results") = False

'Opened an ADO connection to the Active Directory Provider

End Sub

 

' ~$~----------------------------------------~$~

Sub ReadRegistryForAD

On Error Resume Next

strRegistryKey0 = ""

strRegistryKey1 = ""

strRegistryKey2 = ""

strRegistryKey3 = ""

'Backing up the registry keys for HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\x\1406

strRegistryKey0 = objWshShell.RegRead ("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\0\1406")

strRegistryKey1 = objWshShell.RegRead ("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1\1406")

strRegistryKey2 = objWshShell.RegRead ("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2\1406")

strRegistryKey3 = objWshShell.RegRead ("HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3\1406")

End Sub

 

 

 

 

' ~$~----------------------------------------~$~

Function CreateNewComputerObject

Dim objContainer, objComputer

On Error Resume Next

'Obtaining the AD OU object information for the OU

Set objContainer = objNS.OpenDSObject("LDAP://" & strDomainControllerFQDN & "/" & strOU, strAccountUserName, strAccountPassword, ADS_SERVER_BIND Or ADS_SECURE_AUTHENTICATION)

'Setting the AD computer account object information

set objComputer = objContainer.Create("Computer", "cn=" & strComputer)

objComputer.Put "sAMAccountName", strComputer & "$"

objComputer.Put "userAccountControl", ADS_UF_PASSWD_NOTREQD Or ADS_UF_WORKSTATION_TRUST_ACCOUNT

objComputer.SetInfo

' Will error here if the computer account object already exists

If Err then

Err.Clear

CreateNewComputerObject = 1

Else

CreateNewComputerObject = 0

End If

End Function

 

 

 

' ~$~----------------------------------------~$~

Function MoveADComputerObject

Dim objContainer, objConn

On Error Resume Next

'Obtaining the AD OU object information for the OU

Set objContainer = objNS.OpenDSObject("LDAP://" & strDomainControllerFQDN & "/" & strOU, strAccountUserName, strAccountPassword, ADS_SERVER_BIND Or ADS_SECURE_AUTHENTICATION)

'Moving the " & strComputerDistinguishedName & " computer account object

objContainer.MoveHere "LDAP://" & strComputerDistinguishedName, vbNullString

If Err then

Err.Clear

MoveADComputerObject = 1

Else

MoveADComputerObject = 0

End If

End Function

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.