{"id":69903,"date":"2005-05-02T16:45:00","date_gmt":"2005-05-02T16:45:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/05\/02\/how-can-i-add-a-site-to-internet-explorers-restricted-sites-zone\/"},"modified":"2005-05-02T16:45:00","modified_gmt":"2005-05-02T16:45:00","slug":"how-can-i-add-a-site-to-internet-explorers-restricted-sites-zone","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-add-a-site-to-internet-explorers-restricted-sites-zone\/","title":{"rendered":"How Can I Add a Site to Internet Explorer\u2019s Restricted 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 site to Internet Explorer\u2019s Restricted Sites zone on a remote computer?<BR><BR>&#8212; NS<\/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, NS. When it comes to scripting, Internet Explorer has a sort of dual personality. If you want to program the application itself, well, you came to the right place: Internet Explorer\u2019s document object model is wide open, and lends itself to doing all sorts of interesting things, things like creating a graphical user interface for your scripts. (For examples, see the new <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/htas.mspx\"><B>HTA Developers Center<\/B><\/A>.) <\/P>\n<P>When it comes to <I>managing<\/I> Internet Explorer, however, it\u2019s a different story, especially if you\u2019re hoping to manage multiple computers across the enterprise. There are a number of Group Policy options for managing Internet Explorer, but very few scripting options for managing Internet Explorer; Internet Explorer doesn\u2019t have a full-fledged WMI provider nor does it expose a COM object that enables you to configure administrative settings. At first glance script writers would appear to be out of luck.<\/P>\n<P>Ah, but first glances can be deceiving. As it turns out, most of Internet Explorer\u2019s configuration settings are stored in the registry, and stored in a manner accessible to scripting. We can\u2019t use a WMI provider to add a site to the Restricted Sites zone and we can\u2019t use an Internet Explorer COM object to add a site to the Restricted Sites zone. But that\u2019s OK: instead we\u2019ll just use a WMI script to modify the registry and add the site that way. <\/P>\n<P>Zone information for Internet Explorer can be found in the following portions of the registry:<\/P>\n<TABLE class=\"\" cellSpacing=\"0\" cellPadding=\"0\" border=\"0\">\n<TBODY>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P>HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P>HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<P>As you might expect, information found in HKEY_CURRENT_USER applies only to the current user (and can vary from user to user) while information found in HKEY_LOCAL_MACHINE applies to everyone who logs on to that computer. You can add a Restricted Site to either location; the one consideration is whether you want that restriction to apply to everyone who uses the computer or only the current user.<\/P>\n<P>So how do we add a site to a security zone? Well, we\u2019re going to need to do the following:<\/P>\n<P><B>Create a registry key<\/B>. For example, to add the fabrikam.com site to a security zone for only the current user, you need to create a registry key named <B>fabrikam.com<\/B> under HKEY_CURRENT_USER\\ Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Domains\\.<\/P>\n<P><B>Create a DWORD registry value<\/B>. The name of the registry value represents the protocols being managed from that site. Because we are talking about the Restricted Sites zone you will likely want to name the registry value <B>*<\/B>; that blocks all protocols from the site. Alternatively, you could name the value, say, <B>http<\/B>, which would block only the HTTP protocol.<\/P>\n<P><B>Assign the registry value the appropriate Internet Explorer security zone<\/B>. Each Internet Explorer security zone is represented by a number. The Restricted Sites zone is number 4; here\u2019s a list including other zones:<\/P>\n<TABLE class=\"dataTable\" id=\"ECE\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Zone<\/B><\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Value<\/B><\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Intranet<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">1<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Trusted Sites<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">2<\/P><\/TD><\/TR>\n<TR class=\"evenRecord\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Internet<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">3<\/P><\/TD><\/TR>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\">Restricted Sites<\/P><\/TD>\n<TD class=\"\">\n<P class=\"lastInCell\">4<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>In the registry a restricted site looks something like this:<\/P><IMG height=\"220\" alt=\"Registry\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/restricted1.jpg\" width=\"375\" border=\"0\"> \n<P><BR>What do you mean you\u2019re bored? We were just about to show you a script that adds fabrikam.com to the Restricted Sites zone:<\/P><PRE class=\"codeSample\">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;)<\/p>\n<p>strKeyPath = &#8220;Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\&#8221; _\n    &amp; &#8220;ZoneMap\\Domains\\fabrikam.com&#8221;\nobjReg.CreateKey HKEY_CURRENT_USER,strKeyPath<\/p>\n<p>strValueName = &#8220;*&#8221;\ndwValue = 4\nobjReg.SetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue\n<\/PRE>\n<P>The script begins by creating a constant named HKEY_CURRENT_USER and setting the value to &amp;H80000001; we do this to indicate which portion of the registry we want to modify. We then connect to the WMI service and to the standard registry provider (<B>root\\default:StdRegProv<\/B>). <\/P>\n<P>Next we specify the registry path for our new registry key; note the fabrikam.com tacked on the end:<\/P><PRE class=\"codeSample\">strKeyPath = &#8220;Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\&#8221; _\n    &amp; &#8220;ZoneMap\\Domains\\fabrikam.com&#8221;\n<\/PRE>\n<P>After specifying the path we then call the <B>CreateKey<\/B> method to create the new registry key.<\/P>\n<P>Now that we have a fabrikam.com registry key we need to add a registry value. In this case we create a registry value named <B>*<\/B> with a value of <B>4<\/B>; that will add fabrikam.com to the Restricted Zones site and will block all Internet protocols. We then call the <B>SetDWORDValue<\/B> method to create our new registry value. If you fire up Internet Explorer and check the Restricted Sites zone you should see fabrikam.com in the list of restricted sites:<\/P><IMG height=\"298\" alt=\"Restricted Sites\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/restricted2.jpg\" width=\"335\" border=\"0\"> \n<P><BR>Note that our sample script is designed to work on the local computer, but it can easily be modified to work on a remote computer; just assign the variable strComputer the name or IP address of that remote machine.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I add a site to Internet Explorer\u2019s Restricted Sites zone on a remote computer?&#8212; NS Hey, NS. When it comes to scripting, Internet Explorer has a sort of dual personality. If you want to program the application itself, well, you came to the right place: Internet Explorer\u2019s document object model [&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":[16,17,31,26,3,5],"class_list":["post-69903","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-desktop-management","tag-internet-explorer","tag-operating-system","tag-registry","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I add a site to Internet Explorer\u2019s Restricted Sites zone on a remote computer?&#8212; NS Hey, NS. When it comes to scripting, Internet Explorer has a sort of dual personality. If you want to program the application itself, well, you came to the right place: Internet Explorer\u2019s document object model [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69903","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=69903"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69903\/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=69903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=69903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=69903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}