(view source code of sid2user.bat as plain text)
@ECHO OFF
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
IF "%~1"=="" GOTO Syntax
IF NOT "%~2"=="" GOTO Syntax
SETLOCAL
FOR /F "tokens=*" %%A IN ('WMIC Path Win32_UserAccount Where "(SID='%~1')" Get Domain^,Name /Format:list ^| FIND "="') DO SET %%A
ECHO.%Domain%\%Name%
ENDLOCAL
GOTO:EOF
:Syntax
ECHO.
ECHO SID2User.bat, Version 1.00 for Windows XP Professional and later
ECHO Return domain\userid for the specified SID
ECHO.
ECHO Usage: SID2USER sid
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
page last modified: 2024-04-16; loaded in 0.0056 seconds