Getting everyone out of TS at end of day

  • Thread starter Thread starter eotrue
  • Start date Start date
E

eotrue

I have configured TS idle time and parameters like that on
the Terminal Services Configuration.

Sometimes people are not out when our database wants to
shut down, and this prevents the database from shutting
down.

My question is, is there a script that I can run at a
scheduled to time to force everyone out of TS?
 
Yes, you can run a script which resets all sessions:

Matthew Harris has posted a command file that does this, in
microsoft.public.win2000.termserv.apps, around the end of april 2003.

Since that discussion used a great number of different threads with
different subjects, I won't give you the links, but a synopsis. You
can search for all articles in Google, use "rwinsta" as the keyword
and "Matthew Harris" as the Author.

The command from the console is:
for /f "tokens=2" %i in ('qwinsta ^| find /i "listen"') do
echo y | rwinsta %i

Be sure to substitute a %%i whereever you see %i appear in the
command, if you run it from a batchfile.

Matthews explanation:
The command is relatively simple, although the way I
constructed it makes it appear quite complex. First of
all, the For command runs the QWinsta command, which shows
all current sessions and listeners on your terminal
server. The output of the QWinsta command is then
searched, using the Find command, for the word "listen".
The word "listen" designates which sessions on your
terminal servers are the listeners, and consequently, if
you reset a listener, all sessions running under that
listener will be reset (thus, if all your sessions are rdp-
tcp, and you reset the rdp-tcp listener, all your sessions
will be reset). The For command then takes the output of
the Find command and looks at the second argument. This
argument is the session number of the listener. The For
command takes the argument and gives it to the RWinsta
command, which will then reset that session (the
listener). The Echo Y command merely says "yes" to
RWinsta asking if you are sure you know what you are doing
(and we do!)

After the command resets the session, everyone will
be able to log back on pretty much immediately.

Lastly...if you want to record what this script says, add
a >> output.txt to the end of the script. This will save
all output from the script to a file called output.txt.
 
Back
Top