Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to determine who's login to a particular computer?

Status
Not open for further replies.

mikeeboy

IS-IT--Management
Jul 3, 2003
13
US
Does anybody here knows any tools that will determine who's currently login to a particular computer?
 
Easy to tell with vbscript. Note: you need to be logged in as an admin or user with admin rights to the target machine.

Code:
'==========================================================================
'
' NAME: WhoIsLoggedInThere.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 3/29/2005
'
' COMMENT: Prompts for a PC name and returns currently logged in user
'
'==========================================================================

strComputer = InputBox("Computer to Query for Logged In User","Search where?")

On Error Resume Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
    Wscript.Echo "UserName: " & objItem.UserName & " is logged in at computer " & strComputer
Next

I hope you find this post helpful.

Regards,

Mark
 
You could do that. Seems a bit much. I gues it depends on what you want to do with the information. Is this a batch inventory type process, or are you just trying to track down who is logged onto a given system at this moment?

nbtstat -A <IP Address>

and checking the WINS registrations might work just fine. It all depends on what you're trying to do.

 
What's a bit much with double clicking a script? I'm confused by your comment xmsre.

My script will allow the input of either the machine name or IP address which I think is more flexible than the solutions you present. Interested in your comments.

I hope you find this post helpful.

Regards,

Mark
 
I suppose if someone else wote it for you and you already had it in a directory on your path ;-) it doesn't make much difference; the effort is the same. I was thinking in terms of writing the script vs. just running nbtstat.

 
Fair enough. I'd rather script things if I know I will execute a command more than a few times.

I hope you find this post helpful.

Regards,

Mark
 
xmsre,

How would nbtstat -A show you whos currently logged into the system? It only displays the Netbios remote machine table.
 
You have an <03> registration for the user like:

Local Area Connection:
Node IpAddress: [169.54.160.92] Scope Id: []

NetBIOS Remote Machine Name Table

Name Type Status
---------------------------------------------
SERVERNAME <00> UNIQUE Registered
DOMAIN <00> GROUP Registered
SERVERNAME <03> UNIQUE Registered
SERVERNAME <20> UNIQUE Registered
DOMAIN <1E> GROUP Registered
USERNAME <03> UNIQUE Registered

MAC Address = 00-B0-D0-DC-E5-87
 
Download pstools from Sysinternals. Use psloggedon. Sytnax- psloggedon \\computername
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top