Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Schedule Reset of Terminal Services Sessions

Posted on 2009-04-10
1
613 Views
Last Modified: 2012-05-06
I run two TS servers on Windows Server 2003 and I seem to have a problem with certain users leaving their TS session open overnight.  Is there a way that I can schedule to reset all TS sessions say at 2:00 AM or something like that?  I considered using the GPO to reset idle TS sessions, but this would also kill an idle session during the day which I do not want to do.

Any suggestions?
0
Comment
Question by:trbbhm
1 Comment
 
LVL 31

Accepted Solution

by:
Henrik Johansson earned 125 total points
ID: 24121331
Create a batch script (bat or cmd) which loops through the output of qwinsta, quser, 'query user' or 'query session' command and reset the session with logoff or rwinsta command.
Sample below to use queyr session and logoff sessions except of console (wdcon) session.
Use tsdiscon command If you want to disconnect the session.
@echo off
for /F "tokens=3,4,5 skip=1" %%a in ('query session') do (
	if "%%b" == "Active" if not "%%c"=="wdcon" logoff %%a
)

Open in new window

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
A quick step-by-step overview of installing and configuring Carbonite Server Backup.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question