How it works :
Use the 'For' loop to search work thru the list of users on the server
Then once it has found the user then execute a logoff command
Notes:
There are 2 cases as the qwinsta doesn't display the formating the same for
disconnected sessions & active sesssions.
REM @echo off
Set servername=citrix123
Set targetname=testuser1
REM For disconnected users
for /F "tokens=1,2,3" %%i in ('qwinsta %targetname% /Server:%servername%') do if %targetname%==%%j logoff %%k /server:%servername%
REM For active users
for /F "tokens=1,2,3" %%i in ('qwinsta %targetname% /Server:%servername%') do if %targetname%==%%i logoff %%j /server:%servername%
No comments:
Post a Comment