Prevent Security Warnings Using ADO With HTAs
April 6th, 2008If you are using the ADO object to connect to a database within an HTA in a networked environment then you will get a rather annoying message box warning about ActiveXObjects.
To prevent this in all my HTAs I start the script off with the following statements (this is in Javascript).
var objShell = new ActiveXObject("WScript.Shell")
objShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\1\\1406", 0, "REG_DWORD")
objShell.RegWrite("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\myServer\\file", 2, "REG_DWORD")
objShell=null
The effect of the first RegWrite is to allow ‘Access data sources across domains’ and then the second write adds my network location (myServer) to the trusted sites.
These can be manually changed from within Internet Explorer as they are the zones settings in Internet Options.
Setting these keys requires no admin rights but they may well get overwritten by Group Policy so it’s best just to include them at the start of the script.
Note that the first time the application is run you will still get the warning as it will have read the old values, but by the next run they will be set.