Need to find username for a specific computer on Network

Posted on 2007-11-15
Last Modified: 2010-04-21
I have a windows network I help administer, and our database of usernames/computers is out of sorts. I have 2 specific computers with unauthorized software on the NIPR network, that I cannot remote into. I need to find out what username is logged onto those computers. Is there a DOS prompt command that will allow me to find a username logged onto the computers, based on having the computer name and IP address?

Question by:WilliamK99
  • 2
LVL 57

Expert Comment

by:Pete Long
ID: 20288057
Find out who's logged In and where.

Option 1 (The Lazy GUI Way)

Get hold of a copy of Angry IP Scanner

Run it > select Options > Select Columns > add the "User Name" Column > then type in the lowest and highest IP address on your LAN and clickStart

Option 2 (From Command Line)
NBTscan is a program for scanning IP networks for NetBIOS name information. It sends NetBIOS status query to each address in supplied range and lists received information in human readable form. For each responded host it lists IP address, NetBIOS computer name, logged-in user name and MAC address.

This program is a successor of a perl script with the same name and does essentially the same thing, being much faster though. NBTscan produces a report like that:

IP address          NetBIOS Name     Server    User                            MAC address
---------------------------------------------------------------------------------------------------------------------------       MYCOMPUTER                    JDOE                        00-a0-c9-12-34-56        WIN98COMP       <server>  RROE                       00-a0-c9-78-90-00    DPTSERVER       <server>  ADMINISTRATOR    08-00-09-12-34-56

First column lists IP address of responded host. Second column is computer name. Third column indicates if this computer shares or is able to share files or printers. For NT machine it means that Server Service is running on this computer. For Windows 95 it means that "I want to be able to give others access to my files" or "I want to be able to allow others to print on my printer(s)" checkbox is ticked (in Control Panel/Network/File and Print Sharing). Most often it means that this computer shares files. Third column shows user name. If no one is logged on from this computer it is same as computer name. Last column shows adapter MAC address.


If you are simply trying to find who is logged into a partticualr Server od PC then try the following commands

net statistics server
net statistics workstation
net user

Or if its only one machine

Copt and paste the code below save it as whois.vbs and run it

-------Cut Below---------
Dim sComputer
Dim oWMI, oComputer
Dim colComputer

sComputer = InputBox("Enter The Computer Name", "Return User","",1500)

Set oWMI = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set colComputer = oWMI.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each oComputer in colComputer
    MsgBox oComputer.UserName,,"Return User"
--------Cut Above-------


To see who is logged on to a particular PC use WilliamK99,


LVL 11

Accepted Solution

bsharath earned 500 total points
ID: 20288059
This is one excellent Hts file which when entered a machine name or ip will get the logged in user details
Save the code to filename.hta.

<title>Login Details of a Machine</title>
     APPLICATIONNAME="Login Details"

<script language="VBScript">

Sub Window_onLoad
      Me.ResizeTo 400,300
    Me.MoveTo ((Screen.Width / 2) - 200),((Screen.Height / 2) - 150)
End Sub

Sub Default_Buttons
      If Window.Event.KeyCode = 13 Then
      End If
End Sub

Sub Get_Login_Details
      strComputer = txt_computer.value
      if strComputer = "" Then
            msgbox "Please enter a computer name or IP Address",vbOKOnly,"No Computer Name or IP Address"
            Exit Sub
      End If
      If Ping(strComputer) = False Then
        msgbox strComputer & " did not respond to ping. No action could be taken.",vbOkOnly, "Cannot continue script."
        Exit Sub
      End If      
      Set objWMIService = GetObject("winmgmts:" _
          & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
      Set colComputer = objWMIService.ExecQuery _
          ("Select * from Win32_ComputerSystem")
      Set colComputerIP = objWMIService.ExecQuery _
          ("Select * from Win32_NetworkAdapterConfiguration")
      Set colSystemInfo = objWMIService.ExecQuery _
          ("Select * from Win32_OperatingSystem",,48)
      For Each objComputer in colComputer
          strUserName = "User Name: " & objComputer.UserName
          strHostName = "Host Name: " & objComputer.Name
      For Each IPConfig in colComputerIP
            If Not IsNull(IPConfig.IPAddress) Then
              For intIPCount = LBound(IPConfig.IPAddress) _
                  to UBound(IPConfig.IPAddress)
                      strIPAddress = strIPAddress & "IP Address: " & IPConfig.IPAddress(intIPCount) & "~"
            end if
      If Right(strIPAddress, 1) = "~" Then
            strIPAddress = Left(strIPAddress, Len(strIPAddress) - 1)
      End If
      strIPAddress = Replace(strIPAddress, "~", vbCrLf)
      For Each objItem in colSystemInfo
           strOS_Caption = "Caption: " & objItem.Caption
           strOS_SPVersion = "SP Version: " & objItem.CSDVersion
           strOS_VerNumber = "Version Number: " & objItem.Version
      MsgBox strUserName & vbcrlf & strHostName & vbcrlf & _
           strIPAddress & vbcrlf & strOS_Caption & vbcrlf & _
           strOS_SPVersion & vbcrlf & strOS_VerNumber, vbOKOnly, "Login Details"
End Sub

Function Ping(strComputer)
      Dim objShell, boolCode
      Set objShell = CreateObject("WScript.Shell")
      boolCode = objShell.Run("Ping -n 1 -w 300 " & strComputer, 0, True)
      If boolCode = 0 Then
            Ping = True
            Ping = False
      End If
End Function


<body STYLE="font:14 pt arial; color:white;filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000033', EndColorStr='#0000FF')" onkeypress='vbs:Default_Buttons'>
      <table width='80%' height = '100%' align='center' border='0'>
            <tr height='20%'>
            <tr height='10%'>
                  <td align='center'>
                        Computer name or IP Address:
            <tr height='20%'>
                  <td align='center'>
                        <input type="text" value="" name="txt_computer" maxlength='15' size='16'>
            <tr height='30%'>
                  <td align='center'>
                        <input type="button" value="Check Machine" name="btn_logindetails"  onClick="Get_Login_Details">
            <tr height='20%'>



Hope this helps...

Author Closing Comment

ID: 31409301
Excellent advice, worked like a charm...Would give an A+ if I could.

Author Comment

ID: 20288221
That was a brilliant program, thanks for your help.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now