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!

"net command" to find out who is logged in ? 1

Status
Not open for further replies.

hellbeach

IS-IT--Management
Apr 15, 2003
243
Hello everyone
Is there any way of finding out who is logged in to a workstation in our LAN using for example the "net" command ?
 
The command to use is:
If your computer name is mycomputer

nbtstat -a mycomputer
 
net session

I like member Hayes47's response, but this is a little hard to interpret.

The Net.exe with the "session" parameter as shown above shows connected Windows stations on a host Windows device offering shares.


 
I also use nbtstat to get the username, but i use this variant:

nbtstat -a computername | find "03"

This will (usually) list 2 lines, one being the computer name, the other the user name.

 
I should mention that username/computername accounts have a type of "(03) UNIQUE" in the nbtstat results, which is why I use the above command.

D
 
If you download the MS support tools there is a command called whoami which display user loged on.
 
Or paste this in a text file and save as a batch file

run it normally to see brief results or run it from a command line with '> C:\logged.txt' appended to it to pipe it to a text file

@ECHO OFF
:: NET WHO command replacement for Windows NT
:: Version 2.10 B
:: Written by Rob van der Woude

:: Keep variables local
SETLOCAL

:: Find domain name
FOR /F "TOKENS=*" %%A IN ('NET USER %USERNAME% /DOMAIN ^| FIND /I "or dom"') DO FOR %%V IN (%%A) DO SET DOMAIN=%%V
FOR /F "TOKENS=1* DELIMS=." %%A IN ('ECHO.%DOMAIN%') DO SET DOMAIN=%%A

:: Find all PCs and display logged on user for each PC
FOR /F "TOKENS=1* DELIMS=\" %%A IN ('NET VIEW /DOMAIN:%DOMAIN%') DO CALL :Who %%A

:: End program
ENDLOCAL
GOTO:EOF

:Who
:: Display logged on user for each PC
FOR /F %%B IN ('NBTSTAT -a %1 ^| FIND "UNIQUE" ^| FIND /V /I "%1" ^| FIND /V /I "%DOMAIN%"') DO ECHO %1 %%B
GOTO:EOF

Gurner

What is Divine Paradox?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top