Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTA Object Required error

Status
Not open for further replies.

E50

IS-IT--Management
Dec 2, 2011
3
US
I am trying to get this code to work without errors. I works fine but gives "object required" error.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "

<head>
<title>Check</title>

<HTA:APPLICATION
APPLICATIONNAME="Look"
SCROLL="yes"
SINGLEINSTANCE="yes"

>

</head>
<br />


<script language="VBScript">
Function Window_Onload
pink.innerHTML = "These are installed list"

End Function




GetAddRemove


Function GetAddRemove

Dim StrComputer
strComputer = "."

Dim bank

Set look = CreateObject ("Scripting.Dictionary")
look.add "Power DVD", "1"
look.add "Configuration Manager Client", "2"
look.add "Lexmark Software", "3"
look.add "Paperport Viewer", "5"
look.add "Microsoft >Net Framework ", "6"
look.add "Microsoft Silverlight", "7"
look.add "Microsoft Office Enterprise 2007", "8"
look.add "Mozilla Firefox", "9"
look.add "EA", "10"
look.add "Client", "11"
look.add "Java", "12"
look.add "Adobe Flash Player", "13"
look.add "web", "14"
look.add "E Client", "15"
look.add "ATI Display Driver", "16"
look.add "Windows XP Service Pack 3", "17"

Dim sVal, sVer Dim cnt, oReg, sBaseKey, eRC, aSubKeys
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "/root/default:StdRegProv")
sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
eRC = oReg.EnumKey(HKLM, sBaseKey, aSubKeys)


Dim sKey
Dim strhtml



For Each sKey In aSubKeys
oReg.GetStringValue HKLM, sBaseKey & sKey, "DisplayName", sVal

oReg.GetStringValue HKLM, sBaseKey & sKey, _
"DisplayVersion", sVer
If look.exists(sValue) Then
strhtml= strhtml & sVal & Space(10) & sVers & "<br/>"


End If
pink.innerHTML = strhtml


Next


End Function
</script>
<body>
<table><tr><td><input type="button" value="Check Programs" name="GETADD" onClick="GetAddRemove"

/></td></tr></table>

<p>
<span id = "pink"></span></p>

</body>
 
I works fine but gives "object required" error

It couldn't possibly work (the way you desire)...

the problem is here

Code:
Function Window_Onload
   pink.innerHTML = "These are installed list"
End Function

what is pink? The span at the bottom of the page that doesn't exist yet? You're asking the HTA to do something with the span before it exists. Why not use
Code:
<span id = "pink">These [programs] are installed</span>

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
It didn't get rid of the error "object required"

Thanks anyway
 
You are calling GetAddRemove before the <span> is made. Notice the line on which the error occurs. Remove the GetAddRemove from the within the <script> tags.

-Geates



"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Arg....That worked. I didn't realize I ahd it in the script. Thanks a million.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top