Thursday, 23 October 2008

Logoff Users remotely within a Windows 2003 server session

Heres a tool called PsTools. It allows you to do such a thing...

Heres a batch file i use quite ofter to utilise this tool...

@echo off
echo "Enter Username (i.e. sean): "
set /p UserName=
echo "Enter Password: "
set /p PassWord=
echo "Enter Server Name (i.e. server1): "
set /p Server=
echo "Commands.... qwinsta - List all logged in users."
echo "Commands.... logoff [UserID] /v - To logoff a user..."
REM - Run psexec util
psexec \\%Server% -u DOMAIN\%UserName% -p %PassWord% cmd
REM - Get current logged in users...
REM - qwinsta
REM - echo "Enter a UserID to Logoff: "
REM - set /p UserID=
REM - Logoff user...
REM - logoff %UserID% /v

No comments: