HTA's in Vista

  • Thread starter Thread starter Pete Gomersall
  • Start date Start date
P

Pete Gomersall

Hi,
Does anyone know why HTA code that previously worked in XP doesn't in Vista?
For example this code taken from the HTA Developers Center on Script Center
works fine in XP and also on Vista if called within a .vbs file however it
doesn't work in Vista when used in a HTA:
Sub GetOSVersion
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objOperatingSystem in colOperatingSystems
Msgbox objOperatingSystem.Caption & " " & _
objOperatingSystem.Version
Next
End Sub

I suspect a change in the security model for the interaction of mshta and IE
7 (protected mode etc) but I am guessing here.
It would be great if someone from MSFTcould provide a link to documentation
on HTA's and Vista.
 
Pete said:
Hi,
Does anyone know why HTA code that previously worked in XP doesn't in
Vista? For example this code taken from the HTA Developers Center on
Script Center works fine in XP and also on Vista if called within a
.vbs file however it doesn't work in Vista when used in a HTA:

I have not even installed Vista so I cannot answer your question.

However, I can say that the likelihood of anyone being able to help will
be limited by your failure to define "doesn't work". What is the failure
mode? Machine crash? Error message? Incorrect results? Acts as if it
does something but nothing happens?
 
All,
For those of you that cannot see the point of the question:
What are the security differences between running HTA's on XP and Vista (as
I suspect that the inherent difference is because of changes in Vista's
security model - particularly IE 7's protected mode)?
Code that works fine in XP doesn't work (as far as I can determine it is
"just ignored" and fails silently without error, preventing any subsequent
lines to run).
For example this code in any HTA on Vista fails silently at the 3rd line,
the second msgBox never executes and no errors are returned.
msgBox "Blah, Blah!"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
msgBox "Blah, Blah!"
The same code in a standard .vbs works fine.
Pete
 
Pete Gomersall said:
All,
For those of you that cannot see the point of the question:
What are the security differences between running HTA's on XP and Vista
(as I suspect that the inherent difference is because of changes in
Vista's security model - particularly IE 7's protected mode)?
Code that works fine in XP doesn't work (as far as I can determine it is
"just ignored" and fails silently without error, preventing any subsequent
lines to run).
For example this code in any HTA on Vista fails silently at the 3rd line,
the second msgBox never executes and no errors are returned.
msgBox "Blah, Blah!"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
msgBox "Blah, Blah!"
The same code in a standard .vbs works fine.
Pete

I have never used Vista either
But I would suggest that HTA scrips are not enabled by default
 
Back
Top