Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for sid2user.bat

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

  1. @ECHO OFF
  2. IF NOT "%OS%"=="Windows_NT" GOTO Syntax
  3. IF      "%~1"=="" GOTO Syntax
  4. IF NOT  "%~2"=="" GOTO Syntax
  5.  
  6. SETLOCAL
  7. FOR /F "tokens=*" %%A IN ('WMIC Path Win32_UserAccount Where "(SID='%~1')" Get Domain^,Name /Format:list ^| FIND "="') DO SET %%A
  8. ECHO.%Domain%\%Name%
  9. ENDLOCAL
  10. GOTO:EOF
  11.  
  12.  
  13. :Syntax
  14. ECHO.
  15. ECHO SID2User.bat,  Version 1.00 for Windows XP Professional and later
  16. ECHO Return domain\userid for the specified SID
  17. ECHO.
  18. ECHO Usage:  SID2USER  sid
  19. ECHO.
  20. ECHO Written by Rob van der Woude
  21. ECHO http://www.robvanderwoude.com
  22.  

page last uploaded: 2017-08-21, 14:26