• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

Schedule Reset of Terminal Services Sessions

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
trbbhm
Asked:
trbbhm
1 Solution
 
Henrik JohanssonSystems engineerCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now