{"id":70623,"date":"2005-01-19T13:13:00","date_gmt":"2005-01-19T13:13:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/01\/19\/how-can-i-change-the-caption-for-the-my-computer-icon\/"},"modified":"2005-01-19T13:13:00","modified_gmt":"2005-01-19T13:13:00","slug":"how-can-i-change-the-caption-for-the-my-computer-icon","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-change-the-caption-for-the-my-computer-icon\/","title":{"rendered":"How Can I Change the Caption for the My Computer Icon?"},"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! Instead of having the My Computer icon on the desktop read <I>My Computer<\/I>, I\u2019d like to replace that with the name of the computer. Can I do that using a script?<BR><BR>&#8212; TG<\/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, TG. We get asked this question quite a bit; apparently a lot of you find it convenient to have the computer name right on the desktop, making it easier for users to know which computer they\u2019re logged on to. If you\u2019d like to automate the process of changing the caption for the My Computer icon, all you need to do is run a script like this one:<\/P><PRE class=\"codeSample\">Const MY_COMPUTER = &amp;H11&amp;<\/p>\n<p>Set objNetwork = CreateObject(&#8220;Wscript.Network&#8221;)\nstrComputer = objNetwork.ComputerName\nSet objShell = CreateObject(&#8220;Shell.Application&#8221;)\nSet objFolder = objShell.Namespace(MY_COMPUTER) \nSet objFolderItem = objFolder.Self\nobjFolderItem.Name = strComputer\n<\/PRE>\n<P>This script begins my declaring a constant named MY_COMPUTER and setting the value to &amp;H11&amp;; this is the value used by the Windows Shell object to locate My Computer. We then use these two lines of code to determine the name of the local computer and store that name in the variable strComputer:<\/P><PRE class=\"codeSample\">Set objNetwork = CreateObject(&#8220;Wscript.Network&#8221;)\nstrComputer = objNetwork.ComputerName\n<\/PRE>\n<P>So far, so good, right? Next, we create an instance of the Shell Application object, and use the Namespace method to bind to the special folder that corresponds to My Computer. We then bind to My Computer\u2019s FolderItem object using this line of code:<\/P><PRE class=\"codeSample\">Set objFolderItem = objFolder.Self\n<\/PRE>\n<P>After we bind to the FolderItem, we have access to folder properties like, well, the folder\u2019s name. To set the caption for My Computer to the name of the computer we simply set the name property to strComputer, the variable containing the computer name:<\/P><PRE class=\"codeSample\">objFolderItem.Name = strComputer\n<\/PRE>\n<P>Just like that, the caption will change, not only for the desktop icon, but also for the My Computer link in the Start menu. <\/P>\n<P>If you decide later on to change the caption back to My Computer, you can always run this script:<\/P><PRE class=\"codeSample\">Const MY_COMPUTER = &amp;H11&amp;<\/p>\n<p>Set objShell = CreateObject(&#8220;Shell.Application&#8221;)\nSet objFolder = objShell.Namespace(MY_COMPUTER) \nSet objFolderItem = objFolder.Self\nobjFolderItem.Name = &#8220;My Computer&#8221;\n<\/PRE>\n<P>Remember, this does not change the name of your computer, it only changes the caption for the My Computer special folder. Renaming a computer is whole \u2018nother story, one we\u2019ll have to deal with some other time. You might note, too that even though we change the caption from My Computer to, say, atl-ws-01, our Shell Application scripts can still find the My Computer special folder without any problem. That\u2019s because the scripts don\u2019t locate My Computer using the string value <I>My Computer<\/I>, but instead locate the special folder using the constant &amp;H11&amp;.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! Instead of having the My Computer icon on the desktop read My Computer, I\u2019d like to replace that with the name of the computer. Can I do that using a script?&#8212; TG Hey, TG. We get asked this question quite a bit; apparently a lot of you find it convenient to have [&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,3,707,5,226],"class_list":["post-70623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-desktop-management","tag-scripting-guy","tag-shell-application","tag-vbscript","tag-windows-explorer"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! Instead of having the My Computer icon on the desktop read My Computer, I\u2019d like to replace that with the name of the computer. Can I do that using a script?&#8212; TG Hey, TG. We get asked this question quite a bit; apparently a lot of you find it convenient to have [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/70623","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=70623"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/70623\/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=70623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=70623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=70623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}