Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Need to find username for a specific computer on Network

Posted on 2007-11-15
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 http://www.petenetlive.com/Downloads/software/ipscan.exe

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.

See http://www.inetcat.org/software/nbtscan.html

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 http://www.sysinternals.com/Utilities/PsLoggedOn.htmlHello WilliamK99,


LVL 11

Accepted Solution

bsharath earned 2000 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

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

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

During and after that shift to cloud, one area that still poses a struggle for many organizations is what to do with their department file shares.
This article explains the fundamentals of industrial networking which ultimately is the backbone network which is providing communications for process devices like robots and other not so interesting stuff.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

636 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