Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for actusr.bat

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

  1. @ECHO OFF
  2. ECHO.
  3.  
  4. :: Windows version check
  5. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  6. ECHO.%* | FIND "?" >NUL
  7. :: Command line parameter check
  8. IF NOT ERRORLEVEL 1 GOTO Syntax
  9. IF NOT [%2]==[] GOTO Syntax
  10.  
  11. :: Keep variable local
  12. SETLOCAL
  13.  
  14. :: Initialize variable
  15. SET WSS=
  16.  
  17. :: Parse command line parameter
  18. IF NOT [%1]==[] FOR /F "tokens=1 delims=\ " %%A IN ('ECHO.%~1') DO SET WSS=%%A
  19.  
  20. :: Use NET VIEW and NBTSTAT to find computers and logged on users
  21. FOR /F "tokens=1 delims=\ " %%a IN ('NET VIEW ^| FIND /I "\\%WSS%"') DO FOR /F "tokens=1 delims= " %%A IN ('NBTSTAT -a %%a ^| FIND /I /V "%%a" ^| FIND "<03>"') DO ECHO.%%a    %%A
  22.  
  23. :: Done
  24. ENDLOCAL
  25. GOTO:EOF
  26.  
  27. :Syntax
  28. ECHO ACTive USeRs, Version 1.00 for Windows NT
  29. ECHO Display logged on users and their workstations.
  30. ECHO.
  31. ECHO Usage:    ACTUSR  [ filter ]
  32. ECHO.
  33. IF     "%OS%"=="Windows_NT" ECHO Where:    filter is the first part of the computer name^(s^) to be displayed
  34. IF NOT "%OS%"=="Windows_NT" ECHO Where:    filter is the first part of the computer name(s) to be displayed
  35. ECHO.
  36. ECHO Example:  ACTUSR PC
  37. ECHO.
  38. ECHO PC0001    USERID_1
  39. ECHO PC0004    USERID_4
  40. ECHO PC0102    ADMINISTRATOR
  41. ECHO.
  42. ECHO Written by Rob van der Woude
  43. ECHO http://www.robvanderwoude.com
  44.  

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