Solved

Schedule Reset of Terminal Services Sessions

Posted on 2009-04-10
1
607 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now