How can I kill - reset idle terminal sessions using Batch or VB Script.

  • Thread starter Thread starter Rubal Jain
  • Start date Start date
R

Rubal Jain

Hello -

How to I kill or reset or disconnect Idle Terminal/Remote Desktop
sessions using any Batch or VB Script on Windows 2000 and Windows 2003
servers.

Can someone help me ..

Thanks.

Rubal Jain
www.Rubal.Net
 
Why not set a time-out limit on Idle sessions in TS Connection
Configuration, and have them <required_action> automatically?

If you absolutely need to do this in a batch file, you would need
the output from the "qwinsta" command, parse it to find Idle
sessions, and kill those with tskill or rwinsta.

--
Vera Noest
MCSE,CCEA, Microsoft MVP - Terminal Server
http://hem.fyristorg.com/vera/IT
*----------- Please reply in newsgroup -------------*

(e-mail address removed) (Rubal Jain) wrote in
 
Hello -

I have two user 'Administrator' and 'User1' who connects TS Session.
If I want to reset session of particual user 'User1' then how do I do
that.

If you can send me a sample script that would be really appreciable.

Thanks once again.

Rubal Jain
http://www.Rubal.net
 
I don't have a complte sample script for you, but you would need
something like this:

for /f "tokens=2" %%i in ('qwinsta /SERVER:servername User1 ^|
find /i "Idle"') do echo y | rwinsta %%i

Warning: the above code has NOT been tested thoroughly.

--
Vera Noest
MCSE,CCEA, Microsoft MVP - Terminal Server
http://hem.fyristorg.com/vera/IT
*----------- Please reply in newsgroup -------------*

(e-mail address removed) (Rubal Jain) wrote in
 
Hello Mr. Jain

were you able to accomplish this? If so, can you help me with the script.
 
Batch to for this

Code:
  REM @echo off
  REM This batch file will read a list of computers in 'computers.txt', query (qwinsta)
  REM the sessions that are currenlty disconnected, then pass them to
  REM reset them using (rwinsta).  It might not be as graceful as a logoff 
  REM but it works.
  
  REM Mike Stone
  REM 06/19/2008
  
  For /F %%A in (computers.txt) do (
  	for /f "tokens=2" %%i in ('qwinsta /SERVER:%%A ^| find /i "disc"') do echo %%i | rwinsta %%i /SERVER:%%A /V
  )

That should do it for you. Modifying the previous post this is what i came up with. I have a list of 5 terminal servers that this runs on with a scheduled task about every half hour to hour...hope this helps.
 
Back
Top