Batch file to disconnect users on Terminal Services January 11, 2010
Posted by Cowboy in Uncategorized.Tags: batch, desktop, remote, services, terminal
trackback
@echo off
rem Force all remote desktop sessions off
query session >session.txt
for /f “skip=2 tokens=3,” %%i in (session.txt) DO logoff %%i
del session.txt
@echo off
echo Force disconnected remote desktop sessions off
query session >session.txt
rem “skip two lines
remĀ read 3 items
rem (default) delimited by space
rem the second token is ‘disconnected’ then logoff the session.
for /f “skip=2 tokens=2,3,4″ %%i in (session.txt) DO if ‘%%j’ == ‘Disc’ logoff %%i
del session.txt
Comments»
No comments yet — be the first.