Setting the computer descriptions that people see when they're browsing the network is one of those odd tasks that isn't easy to centrally manage but can be important in some network environments. Although you can use the Microsoft Management Console (MMC) to perform this task, it's laborious when you have to do so on a remote computer. So, I wrote a script, NetComment.vbs, that lets you quickly check, set, or remove the description for a remote or local computer. You can even use it to check or clear descriptions for multiple computers. (I use the term computer description because that's the value displayed in the Comments field if you browse computers on the network from a Windows Server 2003, Windows XP, or Windows 2000 machine.)
Before I describe how to use NetComment.vbs to get, set, and clear computer descriptions, I want to point out that there's one traditional way to quickly modify a description: Use the Net Config Server command with the /srvcomment parameter. However, this command immediately writes the current LAN Manager Service data to the registry, so the service will no longer be auto-tuning. The only way you can restore auto-tuning is to manually delete all the tuning parameters under the registry key HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters. If you've used the Net Config Server command to set a system's description and need to restore the LAN Manager Service's auto-tuning behavior, see the Microsoft article "Server Service Configuration and Tuning".
You can download NetComment.vbs by clicking the Download the Code Here button near the top of the page. First, I'll show you how to use this script to get, set, and clear computer descriptions on a single computer. Then, I'll show you how to use it for batch operations. I'll also tell you about a few details you need to be aware of.
Getting a computer description. You can check the description for a remote computer by using its IP address or name. For example, the following commands will return a remote computer's description if a description has been set:
The information is returned in the format computer name = computer description. If a description hasn't been set for the computer, you'll receive the message net error 1. This is normal because you're trying to access a registry value that doesn't exist. You'll also receive an error message when a remote computer is unavailable.
You can check the description for the local computer by using its name, its IP address, a period, or nothing at all. So, for example, all of the following commands will return the local computer's description:
Because you can run the script without any arguments, you can use it as a quick point-and-click tool for checking local computer descriptions. (NetComment.vbs works properly in both the WScript and CScript environments.)
Setting or clearing a computer description. To set a description for a remote computer, you just need to add the description as the second argument, with double quotes surrounding it if the description has spaces in it. For example, if you want to set PrintServer02's description as Engineering Printers, you'd use the command
(Although this command wraps here, you'd enter it all on one line at the command prompt. The same holds true for the other commands that wrap.) To set the description for the local computer, you must supply both the computer name and a description, as in
If you fail to provide a computer name when setting a description, the script won't work correctly.
You use the same technique to remove a remote or local computer's description. To remove the description, specify the computer's name and give it an empty description by using a pair of empty double quotes, as in
NetComment 127.0.0.1 ""
As these examples show, you must supply both the computer name and the pair of empty double quotes to clear a description, no matter whether the computer is remote or local.
Using NetComment.vbs for batch operations. Although written for use against one computer at a time, it's possible to use NetComment.vbs with a batch file wrapper to handle multiple computers in one batch operation. I wrote two wrapper scripts: BatchNetComment.cmd, which checks the descriptions for multiple computers, and BatchClearNetComment.cmd, which clears the descriptions for multiple computers. (I didn't write a wrapper script to set descriptions for multiple computers.)
To use the wrapper scripts, save BatchNetComment.cmd and BatchClearNetComment.cmd in the same folder as NetComment.vbs. (You can find these wrapper scripts in the 103377.zip file.) Then, assuming you have a list of computer names saved to the file c:\tmp\nodes.txt (one name per line), use one of the following commands. If you want to check the description for each computer named in the text file, run the command
If you want to clear the description for each computer named in the text file, run the command
A few details to be aware of. There are a few things you should be aware of when using NetComment.vbs and the wrapper scripts:
- You need administrator permissions to successfully change a description.
- Changes to the description might not take effect until after the modified system reboots and has its description propagated over the network.
- NetComment.vbs uses the Windows Management Instrumentation (WMI) Registry Provider to avoid some of the problems that can occur when trying to use other WMI classes for the same job (notably, an occasional issue with using WMI's Put_ on Windows Vista). This also means you need remote access to WMI on the system you're checking or modifying.
- NetComment.vbs will work on Windows 2000 and later. It will also work on earlier versions if WMI is installed.
- BatchNetComment.cmd and BatchClearNetComment.cmd will work on Windows 2000 and later. They use the usebackq option, so they won't work on earlier versions.
- When setting descriptions, NetComment.vbs will silently trim them to no more than 48 characters because long descriptions can cause problems. Windows servers will normally suppress long descriptions, but non-Windows browse masters will pass them on, sometimes causing Windows network services to crash. (For more information about this issue, see "The Service Host Process May Stop Unexpectedly in Windows Server 2003".) Note that if a longer description has already been set, NetComment.vbs will display it as is.
With NetComment.vbs, you can quickly get, set, or clear a computer's description, no matter whether it's a remote or local machine. With BatchNetComment.cmd and BatchClearNetComment.cmd, you can quickly retrieve or remove descriptions for multiple computers. Although these three scripts might not be ideal for every description-change scenario as is, you can modify the core code to meet your specific needs.