Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for ntrole.bat

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

  1. @ECHO OFF
  2. ECHO.
  3.  
  4. :: Check command line and Windows version
  5. IF NOT "%1"=="" GOTO Syntax
  6. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  7.  
  8. :: Actual command to determine role: 1 line only
  9. FOR /F "skip=8 tokens=2 delims=:" %%A IN ('NET ACCOUNTS') DO FOR /F "tokens=1 delims= " %%K IN ('ECHO.%%A') DO SET NTRole=%%K
  10.  
  11. :: Display result
  12. SET NTRole
  13.  
  14. :: Done
  15. GOTO End
  16.  
  17. :Syntax
  18. ECHO NTRole.bat,  Version 1.10 for Windows NT 4 / 2000
  19. ECHO Find out if this batch file runs on a server or a workstation
  20. ECHO.
  21. ECHO Usage:  %~n0
  22. ECHO.
  23. ECHO Written by Rob van der Woude
  24. ECHO http://www.robvanderwoude.com
  25. ECHO Inspired by one of Clay Calvert's newsgroup postings on alt.msdos.batch.nt
  26.  
  27. :End
  28.  

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