Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically add trusted sites to Internet Explorer

I'm doing an IE automation project using WatiN.

When a file to be downloaded is clicked, I get the following in the Internet Explorer Information bar:

To help protect your security, Internet Explorer has blocked this site from downloading files to you computer.

In order to download the report, I can manually add the site to Internet Explorer's list of trusted sites, but I would prefer to check programmatically in .NET to see if the site is trusted and add it to the list if it is not.

FYI, I'm currently using IE7.

like image 826
Even Mien Avatar asked Jun 09 '09 20:06

Even Mien


People also ask

Why can't I add trusted Sites in Internet Explorer?

You cannot add a Web site to the "Trusted sites" zone even when the current user account belongs to the Administrators group. This problem occurs if the "Security Zones: Use only machine settings" Group Policy setting is enabled.

How do I add a trusted site to Internet properties?

Go to Tools > Internet Options > Security. Click the Trusted Sites icon, then click Sites. Enter the URL of your Trusted Site, then click Add. Click Close.


2 Answers

Using powershell it is quite easy.

#Setting IExplorer settings
Write-Verbose "Now configuring IE"
#Add http://website.com as a trusted Site/Domain
#Navigate to the domains folder in the registry
set-location "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
set-location ZoneMap\Domains

#Create a new folder with the website name
new-item website/ -Force
set-location website/
new-itemproperty . -Name * -Value 2 -Type DWORD -Force
new-itemproperty . -Name http -Value 2 -Type DWORD -Force
new-itemproperty . -Name https -Value 2 -Type DWORD -Force
like image 103
Remy van Tour Avatar answered Oct 22 '22 14:10

Remy van Tour


Have a look at this

Basically it looks as if all you have to do is create registry key in

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\DOMAINNAME

then a REG_DWORD value named "http" with value==2

like image 33
Ben Schwehn Avatar answered Oct 22 '22 14:10

Ben Schwehn