Find the Name of the Computer a User Is Logged On To


As a member of a technical support team, I've found that determining the name of the computer a user is logged on to is often helpful in handling the user's Help desk request. Knowing the user's computer name lets me use a remote administration tool such as Computer Management, Event Viewer, or a registry editor to connect to the computer and troubleshoot the problem. I wrote the script ObtainCompNames.vbs, which Web Listing 1 (, InstantDoc ID 40879) shows to obtain users' computer names from the network.

ObtainCompNames.vbs uses netsh.exe, a utility that lets you retrieve WINS name table information from remote systems and perform WINS database administration from the command line. You can find netsh.exe in your Windows OS's Administration Tools Pack. In the script, netsh.exe accesses your company's WINS database and retrieves the IP address associated with the username you enter.

For ObtainCompNames.vbs to work in your environment, you need to install Windows Script Host (WSH) 5.6 and the latest version of the Administration Tools Pack for your OS. WSH 5.6 gives you access to the WScript.Shell object's Exec method, which you need to capture and manipulate the netsh.exe utility's output.

To use ObtainCompNames.vbs, you must have read access to your company's WINS server. You also need to know the WINS server's name, which you must specify in the script. Listing 2 shows the code that you need to customize. In this code, replace WinsServerName with the name of your WINS server.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.