{"id":70443,"date":"2005-02-14T19:26:00","date_gmt":"2005-02-14T19:26:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/02\/14\/how-can-i-add-a-web-site-to-the-trusted-sites-zone\/"},"modified":"2005-02-14T19:26:00","modified_gmt":"2005-02-14T19:26:00","slug":"how-can-i-add-a-web-site-to-the-trusted-sites-zone","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-add-a-web-site-to-the-trusted-sites-zone\/","title":{"rendered":"How Can I Add a Web Site to the Trusted Sites Zone?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" height=\"34\" alt=\"Hey, Scripting Guy! Question\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"> \n<P>Hey, Scripting Guy! How can I add a Web site to the Trusted Sites zone in Internet Explorer?<BR><BR>&#8212; NR<\/P><IMG height=\"5\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" border=\"0\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" height=\"34\" alt=\"Hey, Scripting Guy! Answer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" height=\"288\" alt=\"Script Center\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" align=\"right\" border=\"0\"><\/A> \n<P>Hey, NR. As it turns out, trusted sites are actually stored in the registry; consequently, adding a Web site is simply a matter of creating and configuring a new registry key. For example, suppose you want to trust Microsoft.com. (And, really, who <I>doesn\u2019t<\/I> want to trust Microsoft?) Here\u2019s a script that adds Microsoft.com to the list of trusted sites:<\/P><PRE class=\"codeSample\">On Error Resume Next<\/p>\n<p>Const HKEY_CURRENT_USER = &amp;H80000001<\/p>\n<p>strComputer = &#8220;.&#8221;\nSet objReg=GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)\nstrKeyPath = &#8220;Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\&#8221; _\n    &amp; &#8220;ZoneMap\\Domains\\microsoft.com&#8221;<\/p>\n<p>objReg.CreateKey HKEY_CURRENT_USER, strKeyPath<\/p>\n<p>strValueName = &#8220;http&#8221;\ndwValue = 2<\/p>\n<p>objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, dwValue\n<\/PRE>\n<P>Let\u2019s talk about what\u2019s going on here. We begin by creating a constant HKEY_CURRENT_USER and setting it to the value &amp;H80000001. This constant will be used to access the HKEY_CURRENT_USER portion of the registry and configure Microsoft.com as a trusted site <I>for only the logged-on user<\/I>. What if you wanted to configure Microsoft.com as a trusted site for anyone logging on to the computer? In that case, substitute the constant HKEY_LOCAL_MACHINE for HKEY_CURRENT_USER, and assign HKEY_LOCAL_MACHINE the value &amp;H80000002.<\/P>\n<P>Next we connect to the WMI service and, more specifically, to the Standard Registry Provider. We then assign the following registry path to the variable strKeyPath:<\/P><PRE class=\"codeSample\">Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\microsoft.com\n<\/PRE>\n<P>Note the tail-end of the path: that\u2019s where we put <I>microsoft.com<\/I>, the name of the Web site to be added to the trusted sites. We then call the <B>CreateKey<\/B> method to create a new registry key (microsoft.com) inside Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains.<\/P>\n<P>Still with us? Having created the registry key, we simply need to create and configure a single registry value. In our sample script, we assign the value <I>http<\/I> to the variable strValueName. This will be the name of our new registry value; it also indicates which Internet protocols will be trusted from Microsoft.com. If we want to trust only the ftp protocol, then we\u2019d assign strValueName the value <I>ftp<\/I>; if we want to trust all Internet protocols, then we\u2019d assign strValueName the value * (a single asterisk).<\/P>\n<P>We then assign the value 2 to the variable dwValue. In the world of Internet Explorer, the 2 represents the Trusted Sites zone. You could also use the value 1 to assign a site to the Intranet Sites zone; the value 3 to assign a site to the Internet Sites zone; or the value 4 to assign a site to the Restricted Sites zone.<\/P>\n<P>Finally we use the <B>SetDWORDValue<\/B> method to create our new registry value. Fire up Internet Explorer, click on <B>Tools<\/B>, click on <B>Internet Options<\/B>, and then, on the <B>Security<\/B> tab, select <B>Trusted Sites<\/B> and click the <B>Sites<\/B> button. You should see Microsoft.com among the trusted sites.<\/P><BR>\n<DIV>\n<TABLE class=\"\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\">\n<TBODY>\n<TR>\n<TD class=\"\"><A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/resources\/qanda\/feb05\/hey0214.mspx#top\"><IMG height=\"9\" alt=\"Top of page\" src=\"http:\/\/www.microsoft.com\/technet\/mnplibrary\/templates\/MNP2.Common\/images\/arrow_px_up.gif\" width=\"7\" border=\"0\"><\/A><A class=\"topOfPage\" href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/resources\/qanda\/feb05\/hey0214.mspx#top\">Top of page<\/A><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I add a Web site to the Trusted Sites zone in Internet Explorer?&#8212; NR Hey, NR. As it turns out, trusted sites are actually stored in the registry; consequently, adding a Web site is simply a matter of creating and configuring a new registry key. For example, suppose you want [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[31,26,3,5],"class_list":["post-70443","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-operating-system","tag-registry","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I add a Web site to the Trusted Sites zone in Internet Explorer?&#8212; NR Hey, NR. As it turns out, trusted sites are actually stored in the registry; consequently, adding a Web site is simply a matter of creating and configuring a new registry key. For example, suppose you want [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/70443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=70443"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/70443\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=70443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=70443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=70443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}