{"id":69833,"date":"2005-05-11T11:27:00","date_gmt":"2005-05-11T11:27:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/05\/11\/how-can-i-rename-a-local-area-connection\/"},"modified":"2005-05-11T11:27:00","modified_gmt":"2005-05-11T11:27:00","slug":"how-can-i-rename-a-local-area-connection","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-rename-a-local-area-connection\/","title":{"rendered":"How Can I Rename a Local Area Connection?"},"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 rename a local area connection?<BR><BR>&#8212; AP<\/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, AP. You know, you hurt our feelings here: we Microsoft types spent a lot of time coming up with clever and catchy names like Local Area Connection, Local Area Connection 2, and Local Area Connection 3. And now you say you want to <I>change<\/I> those names? That hurts.<\/P>\n<P>But you know what they say: the customer is always right. Give us a minute to dry our tears and then we\u2019ll show you a script that changes the name of Local Area Connection 2 to Home Office Connection.<\/P>\n<P>OK, we\u2019re better now:<\/P><PRE class=\"codeSample\">Const NETWORK_CONNECTIONS = &amp;H31&amp;<\/p>\n<p>Set objShell = CreateObject(&#8220;Shell.Application&#8221;)\nSet objFolder = objShell.Namespace(NETWORK_CONNECTIONS)<\/p>\n<p>Set colItems = objFolder.Items\nFor Each objItem in colItems\n    If objItem.Name = &#8220;Local Area Connection 2&#8221; Then\n        objItem.Name = &#8220;Home Office Connection&#8221;\n    End If\nNext\n<\/PRE>\n<P>You might not be aware of this, but network connections are actually housed in a Windows special folder. Of course, this particular folder is <I>really<\/I> special: instead of having a path like C:\\Documents and Settings\\kenmyer\\My Documents it has a path like this:<\/P><PRE class=\"codeSample\">::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D\n}\\::{7007ACC7-3202-11D1-AAD2-00805FC1270E}\n<\/PRE>\n<P>Yikes! But that\u2019s OK. You won\u2019t have much success passing a folder path like that to the <B>dir<\/B> command, but you <I>can<\/I> use the <B>Shell<\/B> object to bind to the path, list all the items (that is, all the network connections) found in the folder, <I>and<\/I> rename any of those items. And that\u2019s exactly what our script does.<\/P>\n<P>We begin by defining a constant named NETWORK_CONNECTIONS and assigning it the value &amp;H31&amp;; we\u2019ll use this constant to tell the Shell object which special folder we want to work with. We then create an instance of the <B>Shell.Application<\/B> object, then use the <B>Namespace<\/B> method to bind to the Network Connections folder. That\u2019s what we do here:<\/P><PRE class=\"codeSample\">Set objShell = CreateObject(&#8220;Shell.Application&#8221;)\nSet objFolder = objShell.Namespace(NETWORK_CONNECTIONS)\n<\/PRE>\n<P>After we bind to the Network Connections folder we can start doing something a bit more interesting. To begin with, we use the <B>Items<\/B> method to return a list of all the items found in the folder; because we\u2019re dealing with the Network Connections folder that\u2019s going to be a list of all the network connections on the computer. We then set up a For Each loop to iterate through the collection, checking to see if any of the connections have the <B>Name<\/B> Local Area Connection 2. If they do, we simply use the Shell object to change the Name to Home Office Connection. That\u2019s what we do here:<\/P><PRE class=\"codeSample\">For Each objItem in colItems\n    If objItem.Name = &#8220;Local Area Connection 2&#8221; Then\n        objItem.Name = &#8220;Home Office Connection&#8221;\n    End If\nNext\n<\/PRE>\n<P>That\u2019s all you have to do: Local Area Connection 2 will now be named Home Office Connection and all will be right with the world.<\/P>\n<P>And before you ask, the answer is no: we will <I>never<\/I> change the name of the Scripting Guys. Ever. <\/P>\n<P>Well, unless &#8211; taking a cue from major league sports &#8211; someone would be interesting in buying the naming rights to the Scripting Guys. The Fabrikam Scripting Guys? Contoso Corporation Presents the Scripting Guys? We\u2019re open to offers\u2026.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I rename a local area connection?&#8212; AP Hey, AP. You know, you hurt our feelings here: we Microsoft types spent a lot of time coming up with clever and catchy names like Local Area Connection, Local Area Connection 2, and Local Area Connection 3. And now you say 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":[36,37,3,5],"class_list":["post-69833","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-client-side-management","tag-networking","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I rename a local area connection?&#8212; AP Hey, AP. You know, you hurt our feelings here: we Microsoft types spent a lot of time coming up with clever and catchy names like Local Area Connection, Local Area Connection 2, and Local Area Connection 3. And now you say you want [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69833","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=69833"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/69833\/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=69833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=69833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=69833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}