13

I have the IP addresses of some computers on my network. Is there any command line tool like PsExec, which can take the IP Address as input and find out the username of the currently logged in user? I can install stuff on my workstation, but not the others. I can also run Metasploit / NMap / any other such program on my workstation.

Andrea
  • 1,516
  • 4
  • 17
  • 19
Neil
  • 769
  • 2
  • 10
  • 18

4 Answers4

10

Try this:

wmic.exe /node:"IP-or-HostName" ComputerSystem Get UserName

Example:

wmic.exe /node:"172.28.1.100" ComputerSystem Get UserName

Output:

UserName
DOMAIN\User

(Yes, /node value must be quoted)

  • 2
    Worked for me. I needed to run cmd as domain Administrator or else I got an error "Access is denied". – Otiel Jan 22 '15 at 16:01
  • Apparently you have two accounts: [account one](//superuser.com/users/141462) and [account two](//superuser.com/users/128275). You might wish to utilise [this Help Center tutorial](//superuser.com/help/merging-accounts) and ask the Super User staff to merge the accounts. – robinCTS Aug 03 '18 at 13:38
6

For Windows boxes get psLoggedOn. It tells you who is currently signed into the box via console/rdp and who is connected via network shares.

If you don't want to install an app, there is also the commands qwinsta and query session that you can run from the command line like this:

qwinsta /server:name_of_host or query session /server:name_of_host
I say Reinstate Monica
  • 25,487
  • 19
  • 95
  • 131
MikeJ
  • 746
  • 3
  • 7
  • 17
  • Oh awesome, theres a PsTool for it. I feel stupid. Anyhow, do these PsTools work on the default Windows XP configuration, without requiring anything to be installed on the remote computer? – Neil May 26 '10 at 11:41
  • Correct. Firewall or disabling WMI will get in the way but often the windows firewall even when on contains an exception for WMI. – MikeJ Jun 11 '10 at 18:02
  • Above command gives ' Access denied' for me, Any idea? – chk.buddi Apr 15 '20 at 18:50
1

Check out MetaLAN

Sathyajith Bhat
  • 61,504
  • 38
  • 179
  • 264
0

You can do this with the following commands. This works because any logged in user would run explorer.exe automatically after signing in:

for /f "TOKENS=1,2,*" %%a in ('tasklist /s %PCNAME% /FI "IMAGENAME eq explorer.exe" /FO LIST /V') do if /i "%%a %%b"=="User Name:" (set domain_user=%%c)    
for /f "TOKENS=1,2 DELIMS=\" %%a in ("%domain_user%") do set domain=%%a && set user=%%b
I say Reinstate Monica
  • 25,487
  • 19
  • 95
  • 131
Minor
  • 1
  • 1