PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

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

 
 
Rubal Jain
Guest
Posts: n/a
 
      7th Jul 2004
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
 
Reply With Quote
 
 
 
 
Vera Noest [MVP]
Guest
Posts: n/a
 
      7th Jul 2004
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 Removed) (Rubal Jain) wrote in
news:(E-Mail Removed):

> 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

 
Reply With Quote
 
Rubal Jain
Guest
Posts: n/a
 
      8th Jul 2004
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
 
Reply With Quote
 
Vera Noest [MVP]
Guest
Posts: n/a
 
      8th Jul 2004
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 Removed) (Rubal Jain) wrote in
news:(E-Mail Removed):

> 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

 
Reply With Quote
 
=?Utf-8?B?c25hbmRhbg==?=
Guest
Posts: n/a
 
      4th Sep 2004
Hello Mr. Jain

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


"Vera Noest [MVP]" wrote:

> 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 Removed) (Rubal Jain) wrote in
> news:(E-Mail Removed):
>
> > 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

>

 
Reply With Quote
 
New Member
Join Date: Jun 2008
Posts: 1
 
      19th Jun 2008
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A script/batch to kill a batch file from scheduled tasks? Bogdan Windows XP Configuration 1 31st Jul 2009 06:05 AM
Idle Sessions =?Utf-8?B?RGF2ZQ==?= Microsoft Windows 2000 Terminal Server Clients 1 7th Apr 2005 08:28 PM
Windows 2003 server. Kill terminal services sessions on a colocation Hugo Microsoft Windows 2000 Terminal Server Clients 1 25th Feb 2004 12:54 PM
Idle Terminal Sessions Larry Microsoft Windows 2000 Terminal Server Clients 1 3rd Dec 2003 03:30 PM
Logoff Idle Terminal sessions Larry Microsoft Windows 2000 Terminal Server Clients 1 3rd Dec 2003 01:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:55 PM.