HTA Error about IE Safety Settings

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
jwestan
Posts: 48
Joined: Wed Mar 18, 2009 2:48 am

HTA Error about IE Safety Settings

Post by jwestan » Wed Mar 18, 2009 2:48 am

Hi everyone,
I am getting an Internet Explorer Error "Safety Settings on this computer prohibit accessing a data source on another domain" when running my HTA. I recently added tabs to it with Javascript but the part in the HTA that is giving the error I have been using for a while now with no issues.
I have checked my IE settings but did not see anything that jumped out at me.
Anyone have any suggestions?
Here is the function that is causing the error. It is saying that the objConnection.open line is causing the error.
Thanks.

Function PCNumCnt(strPCNumber) Dim strGetPCNum, objCommand, objConnection, objRecordSet 'On Error Resume Next 'This function will be used to gather the number of PC#'s in EP. Set objCommand = CreateObject("ADODB.Command") Set objConnection = CreateObject("ADODB.Connection") objConnection.Provider = "SQLOLEDB" objConnection.ConnectionTimeout=120 objConnection.Open "Persist Security Info=False;Data Source="& DataSrc &"; Database="& DBName &"; user id="& DBUser &"; password="& DBPass &"" Set objCommand.ActiveConnection = objConnection objCommand.CommandText = _ " Declare @PC_Number nvarchar (50) "_ & "Select @PC_Number = '" & strPCNumber & "' "_ & "select count(1) as Count_Number "_ & "from " & DBNameWH & "..Loc_bu bu (NOLOCK) "_ & "where bu.name = @PC_Number "_ Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst strGetPCNum = objRecordSet.Fields("Count_Number").Value PCNumCnt = strGetPCNum objRecordSet.Close objConnection.Close End Function

User avatar
jwestan
Posts: 48
Joined: Wed Mar 18, 2009 2:48 am

HTA Error about IE Safety Settings

Post by jwestan » Wed Mar 18, 2009 2:48 am

Hi everyone,
I am getting an Internet Explorer Error "Safety Settings on this computer prohibit accessing a data source on another domain" when running my HTA. I recently added tabs to it with Javascript but the part in the HTA that is giving the error I have been using for a while now with no issues.
I have checked my IE settings but did not see anything that jumped out at me.
Anyone have any suggestions?
Here is the function that is causing the error. It is saying that the objConnection.open line is causing the error.
Thanks.

Function PCNumCnt(strPCNumber) Dim strGetPCNum, objCommand, objConnection, objRecordSet 'On Error Resume Next 'This function will be used to gather the number of PC#'s in EP. Set objCommand = CreateObject("ADODB.Command") Set objConnection = CreateObject("ADODB.Connection") objConnection.Provider = "SQLOLEDB" objConnection.ConnectionTimeout=120 objConnection.Open "Persist Security Info=False;Data Source="& DataSrc &"; Database="& DBName &"; user id="& DBUser &"; password="& DBPass &"" Set objCommand.ActiveConnection = objConnection objCommand.CommandText = _ " Declare @PC_Number nvarchar (50) "_ & "Select @PC_Number = '" & strPCNumber & "' "_ & "select count(1) as Count_Number "_ & "from " & DBNameWH & "..Loc_bu bu (NOLOCK) "_ & "where bu.name = @PC_Number "_ Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst strGetPCNum = objRecordSet.Fields("Count_Number").Value PCNumCnt = strGetPCNum objRecordSet.Close objConnection.Close End Function

User avatar
jvierra
Posts: 13573
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA Error about IE Safety Settings

Post by jvierra » Wed Mar 18, 2009 3:14 am

Does this function work when run as a vbscript.

Th e function itself cannot cause this error by itself when run in an HTA. It may cause an error if you are using IEFrame(frame or iframe) or if you are using certain other ActiveX controls in the page. It will also happen if you are trying to launch "InternetExplorere.Applicatation" from the HTA.

The code you posted probably has nothing to do withthe error as there is nothing in the code that touches IE or any IE components.


User avatar
jvierra
Posts: 13573
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA Error about IE Safety Settings

Post by jvierra » Wed Mar 18, 2009 3:31 am

rasimmer -

Have you seen it give this error? I know certain ActiveX controls will fail to load when run from an "untrusted" location such as the Internet or a network share. I don't remember seeing this error under those circumstances. If that is the cause then it is an easy fix.

Good point to check.

User avatar
jvierra
Posts: 13573
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA Error about IE Safety Settings

Post by jvierra » Wed Mar 18, 2009 3:41 am

I tested this idea and, on a Windows 2003 domain. it does not fail even when I get a warning about the location may not be safe for some things. The HTA overrides that if I choose to go ahead.

An HTA should not come under cross domain scripting restrictions except when using an IFRAME. This is well documented on teh MS HTA supprt site and should be findable on Google.

If we are getting these errors with an HTA and no IFRAME is in use then there is something else that is set up wrong.

I many cases teh indiscriminant use of "On Error Resume Next" in an HTA will cause odd failures so this might be another thing to look for.

On thing that I would question is why the user thinks that the line number is correct? Is this from a debugger trap?

I return to my former and most important question. Can this function be run as a VBScript (.VBS file). If it can't then perhaps ADO is damaged.

jvierra2009-03-18 10:44:05

User avatar
rasimmer
Posts: 182
Joined: Fri Jan 30, 2009 12:37 am

HTA Error about IE Safety Settings

Post by rasimmer » Wed Mar 18, 2009 3:49 am

If JVierra is correct and ADO is broken, you could probably try running the HTA from another system to see if you get the same error. If ADO is broken, you can try reloading MDAC on the system by going to C:WindowsInf and right-click on Mdac.inf and "Install"

User avatar
jvierra
Posts: 13573
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA Error about IE Safety Settings

Post by jvierra » Sat May 30, 2009 2:40 am

woowil - HTA disables these items by default so htere is no need to changes them in an HTA.

I believe that if yuo navigate an HTA to an external web site (Internet) then the secirity settings will then revert to IE settings. This is still a dangerous practice as an HTA runs at a much lower security setting than IE does.


User avatar
drlandau
Posts: 16
Joined: Tue Feb 22, 2011 5:59 pm

HTA Error about IE Safety Settings

Post by drlandau » Wed Nov 11, 2009 5:05 am

Hi, about the domain error its because of the security settings in IE (IE is used when launching HTA's), open "Internet Setting", goto "Security" tab, select zone "Internet", press button "Custom level..." , scroll to the "Miscellaneous" section and change "Access data sources across domains" from "Disabled" to "Prompt".This should make AAC prompt instead of fail.Note I haven't tried AAC myself yet, but I had the same problem with a HTA I made myself.

User avatar
jvierra
Posts: 13573
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA Error about IE Safety Settings

Post by jvierra » Wed Nov 11, 2009 5:52 am

drlandau - welcom aboard. Note that this topic is a bit old but that's ok.

Also note that - IE is NOT used when launching an HTA an HTA is launched via MSHTA.EXE in the Window system folder. It provides a safely lowered security fence assuming reasonble care will be taken.

It is a very bad idea to allow access to data across domains. This will not occur with an HTA which is why it is necessary to be careful when using an HTA. YOu can get unprotected access to data from untrusted sources.

If you are using an HTA in an unsafe manner then you are probably doing something incorrectly. Lowering IE security fence is not a goos way to fix problems.

Noramally data accessed from an HTA is local data on the local LAN or domian. If yuo are having issues with this then IE is broken. The locval machine needs to be trusted. Sometimes this indicates that the machine is infected with a trojan that switches the firewall definition so everything outside of the local machine is trusted but the local machine isn't. It's an old hack but may still be around. It is one of mayny reasons why I am posting this warning about using IE settings to solve HTA issues.

You should NECER set the Internet to allow Access Across Domains. It is a gateway to many know and very active exploits. It would be better to add the remote sitge if trusted, to the "trusted sites" zone which will allow certain kinds of access. If this is due to use of teh IFRAME cotrol then other methods are available to solve the issue. It is caused by hosting teh HTA locally and pointing a frame at an untrusted source in certain unsafe ways. I believe that was not the issue here,

At the time of this pst I did extensive testing and was able to ascertain that any properly set up system never had these errors. THe user gave up without a proper fix. I hope he/she didn't find their system compromised after the hack. That hack should NEVER be needed. I have done many HTAs sinilar to this one and have only seen this issue on a system that was damaged or incorrectly patched.





User avatar
jvierra
Posts: 13573
Joined: Tue May 22, 2007 9:57 am
Contact:

HTA Error about IE Safety Settings

Post by jvierra » Wed Nov 11, 2009 7:10 am

Nope - doesn't use IE at all. It dowes uyse the browser API and controls though.

The browser zones affect teh whole machine and so mau also affect an HTA. That is why you don't want to use the zones to openaccess as it allows everything on the machine to do this.

Locked