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...

http://kodethoughts.blogspot.com/2006/12/kill-remote-user-session-remotely.html


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

@echo off
 
:BEGIN
 
CLS
 
COLOR A
 
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
 
:END

No comments: