Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for netwho2.bat

(view source code of netwho2.bat as plain text)

  1. @ECHO OFF
  2. :: NET WHO command replacement for Windows NT
  3. :: Version 2.10 B
  4. :: Written by Rob van der Woude
  5.  
  6. :: Keep variables local
  7. SETLOCAL
  8.  
  9. :: Find domain name
  10. FOR /F "TOKENS=*" %%A IN ('NET USER %USERNAME% /DOMAIN ^| FIND /I "or dom"') DO FOR %%V IN (%%A) DO SET DOMAIN=%%V
  11. FOR /F "TOKENS=1* DELIMS=." %%A IN ('ECHO.%DOMAIN%') DO SET DOMAIN=%%A
  12.  
  13. :: Find all PCs and display logged on user for each PC
  14. FOR /F "TOKENS=1* DELIMS=\" %%A IN ('NET VIEW /DOMAIN:%DOMAIN%') DO CALL :Who %%A
  15.  
  16. :: End program
  17. ENDLOCAL
  18. GOTO:EOF
  19.  
  20. :Who
  21. :: Display logged on user for each PC
  22. FOR /F %%B IN ('NBTSTAT -a %1 ^| FIND "UNIQUE" ^| FIND /V /I "%1" ^| FIND /V /I "%DOMAIN%"') DO ECHO  %1    %%B
  23. GOTO:EOF
  24.  

page last modified: 2024-04-16; loaded in 0.0074 seconds