Logoff Disconnected Users

i have a windows server 2003 with sp2
we using that by terminal server..
so users connect this server via remote desktop connection
i did automatically logoff if idle time is 15 minutes..
but i want to log off disconnected users via script (like vbs)
so what can i do ?
thnx and regards...
Who is Participating?
oBdAConnect With a Mentor Commented:
Save the script below as LogoffDisconnected.cmd or Whatever.cmd.
It's in test mode and will only display the "logoff" command(s) it would otherwise run. Simply remove the capitalized ECHO (so that line reads 'set test=') to run it for real.

@echo off
set Server=%ComputerName%
REM set 'test' to an empty string instead of ECHO to run it for real:
set test=ECHO
for /f "tokens=1*" %%a in ('query session /server:"%Server%" ^| find /i "disc"') do (
  %test% logoff /server:"%Server%" "%%a" /v

Open in new window

Venugopal NCommented:
asyabAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.