Subscribe to Windows IT Pro
January 17, 2006 12:00 AM

Determine the Machines Users Are Logged On To

Windows IT Pro
InstantDoc ID #48796
Rating: (1)
Downloads
48796.zip

Many times, I need to find out the computers users are currently logged on to. Thus, I wrote FindLogon.vbs, which locates the machine a user is logged on to by looking at the open sessions on the user's home server and determining which computers those sessions-originate from.

Listing 1 shows an excerpt from FindLogon.vbs. You can download the entire script from the Windows Scripting Solutions Web site. Go to http://www.windowsitpro.com/windowsscripting, enter 48796 in the InstantDoc ID text box, then click the 48796.zip hotlink. I wrote this script for machines running Windows XP. To launch the script, use the command

CScript FindLogon.vbs domain\nt_id 

where domain is the name of the user's domain and nt_id is the user's logon name.

FindLogon.vbs assumes that the home directory field in the user's domain account properties isn't empty. This field contains the name of the user's home server, which is needed to access that server's sessions. When a user accesses resources on a server, an active session is established-between the user's computer and that server. Sessions are managed by the file service. Thus, to obtain session objects, FindLogon.vbs binds to the LanmanServer service, as Listing 1 shows. The script then iterates through each session object to obtain the name of the computer involved in that session.

Related Content:

ARTICLE TOOLS

Comments
  • Timothy
    5 years ago
    Nov 12, 2007

    I see the echo username & " logins to : "

    but nothing else shows

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.