@ECHO OFF :: Check OS version IF NOT "%OS%"=="Windows_NT" GOTO Syntax :: For Windows NT 4/2000 SETLOCAL ENABLEEXTENSIONS :: Check command line parameter :: Delims is a backslash, followed by a TAB and a space FOR /F "tokens=1 delims=\ " %%A IN ('ECHO.%*') DO SET Host=%%A IF "%Host%"=="" GOTO Syntax PING %Host% | FIND "TTL=" >NUL IF ERRORLEVEL 1 GOTO Syntax :: Find out who is logged on to the remote computer SET UserID= FOR /F "skip=6 eol=U tokens=1* delims=\" %%A IN ('PSLOGGEDON \\%Host% ^| FIND /V "NT AUTHORITY"') DO CALL :UserID %%B :: Find out the remote user's Security ID FOR /F "tokens=7 delims= " %%A IN ('GETSID \\%Host% %UserID% \\%Host% %UserID% ^| FIND " is "') DO SET SID=%%A :: Display the values SET Host SET UserID SET SID ::Done GOTO End :UserID IF NOT DEFINED UserID SET UserID=%1 GOTO:EOF :Syntax ECHO. ECHO RemoteSID.bat, Version 2.11 for Windows NT 4 / 2000 ECHO Display remote PC's logged on user and Security ID ECHO. IF "%OS%"=="Windows_NT" ECHO Usage: %~n0 \\remote_hostname IF NOT "%OS%"=="Windows_NT" ECHO Usage: %0 \\remote_hostname ECHO. ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com ECHO. ECHO Note: Uses GETSID.EXE from the Microsoft Windows NT 4 Resource Kit ECHO http://www.microsoft.com ECHO Also uses PSLOGGEDON.EXE Version 1.5 from SysInternals.com ECHO http://www.sysinternals.com :End ENDLOCAL IF "%OS%"=="Windows_NT" ENDLOCAL