{"id":67363,"date":"2006-05-09T09:46:00","date_gmt":"2006-05-09T09:46:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2006\/05\/09\/how-can-i-clear-the-list-of-urls-that-appear-in-the-internet-explorer-address-bar\/"},"modified":"2006-05-09T09:46:00","modified_gmt":"2006-05-09T09:46:00","slug":"how-can-i-clear-the-list-of-urls-that-appear-in-the-internet-explorer-address-bar","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-clear-the-list-of-urls-that-appear-in-the-internet-explorer-address-bar\/","title":{"rendered":"How Can I Clear the List of URLs That Appear in the Internet Explorer Address Bar?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I clear the list of URLs that appear in the Internet Explorer address bar?<BR><BR>&#8212; GA<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, GA. You know, if you\u2019ve ever pondered the question, \u201cWhat is it that makes the Scripting Guys different from other Microsoft employees?\u201d well, we can save you some time and trouble by just giving you the answer: the Scripting Guys are dumber than other Microsoft employees. For example, it turns out that the list of URLs that appear in the Internet Explorer address bar drop-down list are stored in the registry; to be more specific, they are stored in this registry key:<\/P><PRE class=\"codeSample\">HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\TypedURLs\n<\/PRE>\n<P>The obvious implication? Delete the values found in that registry key and you\u2019ll delete the list of URLs that appear in the Internet Explorer address bar.<\/P>\n<P>Of course, most Microsoft employees know how dangerous it is to mess around with the registry. For example (and we\u2019re not making this up), when we wrote the <I>Microsoft Windows 2000 Scripting Guide<\/I> we included a chapter on writing scripts that <A href=\"http:\/\/null\/technet\/scriptcenter\/guide\/sas_reg_overview.mspx\" target=\"_blank\"><B>manipulate the registry<\/B><\/A>. That was fine, but our editors at the time tried to make us include the following disclaimer after each and every script in the chapter:<\/P>\n<P>\u201cChanging the registry with a script can easily propagate errors. The scripting tools bypass safeguards, allowing settings that can damage your system, or even require you to reinstall Windows. It is recommended that you do not use scripts to change the registry.\u201d<\/P>\n<P>In other words, \u201cHere\u2019s a script that changes a value in the registry. Now don\u2019t use it.\u201d<\/P>\n<P>But, like we said, the Scripting Guys are \u2026 different \u2026 than other Microsoft employees. Without even bothering to ponder the possible consequences we wrote the following script, one that deletes all the registry values in the TypedURLs registry key:<\/P><PRE class=\"codeSample\">Const HKEY_CURRENT_USER = &amp;H80000001<\/p>\n<p>strComputer = &#8220;.&#8221;<\/p>\n<p>Set objRegistry = GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyPath = &#8220;Software\\Microsoft\\Internet Explorer\\TypedURLs&#8221;<\/p>\n<p>objRegistry.EnumValues HKEY_CURRENT_USER, strKeyPath, arrValueNames, arrValueTypes<\/p>\n<p>For Each strValue in arrValueNames\n    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValue\nNext\n<\/PRE>\n<P>Was it a bad idea to do that on our actual work computer, as opposed to, say, running the script on a test machine? Probably. But all\u2019s well that ends well: as near as we can tell, not only did this script clear the list of URLs from the address bar, but it didn\u2019t cause any problems along the way, either. As usual, you run scripts that play around with the registry at your own risk, but this one seems to work just fine.<\/P>\n<P>Let\u2019s take a few minutes to walk through the script and talk about how it <I>does<\/I> work. To begin with, we define a constant named HKEY_CURRENT_USER and set the value to &amp;H80000001; this simply tells the script which registry hive to work with. We then use these two lines of code to connect to the WMI service on the local computer:<\/P><PRE class=\"codeSample\">strComputer = &#8220;.&#8221;<\/p>\n<p>Set objRegistry = GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)\n<\/PRE>\n<P>And, yes, this script <I>can<\/I> be modified to work against a remote computer: all you have to do is assign the name of the remote machine to the variable strComputer. For example:<\/P><PRE class=\"codeSample\">strComputer = &#8220;atl-ws-01&#8221;\n<\/PRE>\n<P>So far, so good, right? After connecting to the WMI service we assign the registry path within HKEY_CURRENT_USER (Software\\Microsoft\\Internet Explorer\\TypedURLs) to a variable named strKeyPath. That brings us to this line of code:<\/P><PRE class=\"codeSample\">objRegistry.EnumValues HKEY_CURRENT_USER, strKeyPath, arrValueNames, arrValueTypes\n<\/PRE>\n<P>As it turns out, each URL that appears in the address bar is stored as a separate registry value: url1, url2, url3, etc. What we\u2019re doing here is using the <B>EnumValues<\/B> method to retrieve a collection of all the registry values found in the TypedURLs key. We give EnumValues four parameters:<\/P>\n<TABLE border=\"0\" cellSpacing=\"0\" cellPadding=\"0\">\n<TBODY>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>HKEY_CURRENT_USER<\/B>, the costant that represents the registry hive.<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>strKeyPath<\/B>, the variable that indicates the registry key we want to work with.<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>arrValueNames<\/B>, an \u201cout\u201d parameter that EnumValues will fill with the names of all the registry values found in TypedURLs.<\/P><\/TD><\/TR>\n<TR>\n<TD class=\"listBullet\" vAlign=\"top\">\u2022<\/TD>\n<TD class=\"listItem\">\n<P><B>arrValueTypes<\/B>, a second out parameter that EnumValues will fill with the registry data type for each value in TypedURLs. For this particular script we don\u2019t care about the data type, but because it\u2019s a required parameter we need to include it.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<P>In other words, after calling EnumValues we\u2019ll get back a collection of all the registry values found in TypedURLs, a collection that will be stored in the variable arrValueNames. That means we can now easily delete each value: all we have to do is set up a For Each loop to walk through the collection and, within that For Each loop, use the <B>DeleteValue<\/B> method to delete each value. That\u2019s what we do here:<\/P><PRE class=\"codeSample\">For Each strValue in arrValueNames\n    objRegistry.DeleteValue HKEY_CURRENT_USER,strKeyPath,strValue\nNext\n<\/PRE>\n<P>As you can see, DeleteValue takes three parameters: the constant HKEY_CURRENT_USER, the variable strKeyPath, and the variable strValue (which simply represents the registry value to be deleted.)<\/P>\n<P>That\u2019s all you have to do. After the registry values have been deleted no items will appear in the Internet Explorer address bar drop-down list. However, as you type new URLs in the address bar new registry values will automatically be created. Over time, you\u2019ll eventually build up a brand-new collection of typed URLs, which you can then delete using this script, ensuring that the great circle of Internet Explorer life goes on.<\/P>\n<TABLE id=\"E1E\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Note<\/B>. One little quirk to watch out for. Suppose you delete all the URLs, then open Internet Explorer and type a new address into the address bar. This address will be immediately added to the drop-down list; however, if you look in the registry you won\u2019t see any new values in TypedURLs. For some reason these new URLs aren\u2019t added to the registry until that instance of Internet Explorer has been terminated. If you close Internet Explorer and <I>then<\/I> check the registry you\u2019ll see your new registry value.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>Like we said, this seems to work just fine, despite the fact that many people would caution you against using a script to delete values from the registry. And now, if you\u2019ll excuse us, someone down the hall needs to borrow a pair of scissors. We\u2019re going to run some over to them right now.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I clear the list of URLs that appear in the Internet Explorer address bar?&#8212; GA Hey, GA. You know, if you\u2019ve ever pondered the question, \u201cWhat is it that makes the Scripting Guys different from other Microsoft employees?\u201d well, we can save you some time and trouble by just giving [&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":[17,31,26,3,167,5],"class_list":["post-67363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-internet-explorer","tag-operating-system","tag-registry","tag-scripting-guy","tag-using-the-internet","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I clear the list of URLs that appear in the Internet Explorer address bar?&#8212; GA Hey, GA. You know, if you\u2019ve ever pondered the question, \u201cWhat is it that makes the Scripting Guys different from other Microsoft employees?\u201d well, we can save you some time and trouble by just giving [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/67363","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=67363"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/67363\/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=67363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=67363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=67363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}