{"id":68383,"date":"2005-12-07T15:40:00","date_gmt":"2005-12-07T15:40:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2005\/12\/07\/how-can-i-change-the-description-for-a-computer\/"},"modified":"2005-12-07T15:40:00","modified_gmt":"2005-12-07T15:40:00","slug":"how-can-i-change-the-description-for-a-computer","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-change-the-description-for-a-computer\/","title":{"rendered":"How Can I Change the Description for a Computer?"},"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! When I use Windows Explorer to connect to a remote computer, I can see a description of that computer in the Details pane. How can I change the description for a computer?<BR><BR>&#8212; GF<\/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, GF. Just to make sure everyone is clear what we\u2019re talking about, we are <I>not<\/I> talking about the Description attribute in Active Directory; instead, we\u2019re talking about the computer description that gets broadcast across the network. (If you\u2019d rather know how to change the Description attribute in Active Directory, see <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/resources\/qanda\/apr05\/hey0429.mspx\"><B>this <\/B><B><I>Hey, Scripting Guy!<\/I><\/B><B> column<\/B><\/A>.)<\/P>\n<P>For example, in Windows XP you can get to the computer description by right-clicking My Computer, clicking <B>Properties<\/B>, and then looking on the <B>Computer Name<\/B> tab in the <B>System Properties<\/B> dialog box:<\/P><IMG height=\"196\" alt=\"Computer Description\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/description1.jpg\" width=\"420\" border=\"0\"> \n<P><BR>And, as you noted, if you connect to this computer using Windows Explorer, the description will appear in the <B>Details<\/B> pane as well:<\/P><IMG height=\"247\" alt=\"Computer Description\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/description2.jpg\" width=\"448\" border=\"0\"> \n<P><BR>We thought it was pretty exciting, too.<\/P>\n<P>So how can you change the description for a computer? Well, you <I>could<\/I> open up Regedit.exe and manually change the registry value HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\lanmanserver\\parameters\\srvcomment. Or, you could just run a script like this one:<\/P><PRE class=\"codeSample\">Const HKEY_LOCAL_MACHINE = &amp;H80000002<\/p>\n<p>strComputer = &#8220;.&#8221;<\/p>\n<p>Set objRegistry = GetObject _\n    (&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyPath = &#8220;System\\CurrentControlSet\\Services\\lanmanserver\\parameters&#8221;\nstrValueName = &#8220;srvcomment&#8221;\nstrDescription = &#8220;Description changed programmatically&#8221;<\/p>\n<p>objRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDescription\n<\/PRE>\n<P>Of course it\u2019s easy; after all this time did you really think we\u2019d suddenly start giving you complicated and convoluted answers to your questions? We begin by defining a constant named HKEY_LOCAL_MACHINE and setting the value to &amp;H80000002; in a minute we\u2019ll use this constant to tell the script which registry hive we want to work with. We then connect to the WMI service (in this case on the local computer, though we can just as easily modify the registry on a remote machine) and bind to the <B>StdRegProv<\/B> class. (Which, as we never tire of telling people, happens to be found in the <B>root\\default<\/B> namespace.)<\/P>\n<P>Next we assign values to three variables:<\/P><PRE class=\"codeSample\">strKeyPath = &#8220;System\\CurrentControlSet\\Services\\lanmanserver\\parameters&#8221;\nstrValueName = &#8220;srvcomment&#8221;\nstrDescription = &#8220;Description changed programmtically&#8221;\n<\/PRE>\n<P>The variable strKeyPath represents the path within the HKEY_LOCAL_MACHINE portion of the registry; strValueName represents the registry value (<B>srvcomment<\/B>) we\u2019re about to change; and strDescription &#8211; that\u2019s right: strDescription represents the new computer description. That\u2019s a very astute observation.<\/P>\n<TABLE class=\"dataTable\" id=\"EVE\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Note<\/B>. We\u2019d tell you that you guys are way better at this stuff than we are, but we don\u2019t want our manager to get any ideas. And yes: getting an idea <I>would<\/I> be a first for a Microsoft manager!<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>All we have to do now is call the <B>SetStringValue<\/B> method, passing HKEY_LOCAL_MACHINE and our three variables as the method parameters:<\/P><PRE class=\"codeSample\">objRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDescription\n<\/PRE>\n<P>Scripts like that really <I>do<\/I> make life worth living, don\u2019t they?<\/P>\n<TABLE class=\"dataTable\" id=\"EOF\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Note<\/B>. Be forewarned that even though this change is made in the registry the new description might not take effect until the computer has rebooted. Just something to keep in mind.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV><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\/dec05\/hey1207.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\/dec05\/hey1207.mspx#top\">Top of page<\/A><\/TD><\/TR><\/TBODY><\/TABLE><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! When I use Windows Explorer to connect to a remote computer, I can see a description of that computer in the Details pane. How can I change the description for a computer?&#8212; GF Hey, GF. Just to make sure everyone is clear what we\u2019re talking about, we are not talking about the [&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":[237,16,31,26,3,5],"class_list":["post-68383","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-basic-computer-information","tag-desktop-management","tag-operating-system","tag-registry","tag-scripting-guy","tag-vbscript"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! When I use Windows Explorer to connect to a remote computer, I can see a description of that computer in the Details pane. How can I change the description for a computer?&#8212; GF Hey, GF. Just to make sure everyone is clear what we\u2019re talking about, we are not talking about the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/68383","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=68383"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/68383\/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=68383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=68383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=68383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}