SQLServerCentral Article

Terminal Services - A Couple Tips

,

The only thing neater than Terminal Services (TS) is

sliced peanut butter. Hopefully

most of you know that TS (aka Remote Desktop) gives you an easy way to do remote

administration. If you've got TS enabled on your server and you can get a

connection, you can log on as if you were there. Saves many trips to the server

room. If you haven't tried it, it's definitely worth exploring.

Enabling TS is up to your administrator of course and comes in two modes.

True TS where the machine is going to be hosting dozens of years running

sessions on it, and administrative where you can have a max of two concurrent

connections. The latter is normally in effect on database servers.

There are a couple different ways to manage TS connections depending on what

OS you're using, it looks like there is even a TS client that will let you

connect from a Mac! For this article I'll be discussing some tips for using TS

from XP.

There are two ways (at least) to manage connections. One is the Terminal

Service Manager (part of the admin pack I believe) which lets you see all the TS

enabled machines, who is connected, etc. The other is the Remote Desktop

Connection, pictured here:

Available as a menu item at Programs, Accessories, Communications, or you can

just do Start, Run, MSTSC.exe.

Type in the computer name, click connect and you're connected to the desktop

of the target computer. The options button offers some nice tweaks, something

else to explore (its four tabs worth). One of the handiest options is the

ability to save your connection locally as a file (with an .rdp extension). Once

saved, you can open the connection again easily by double clicking the file. I

personally prefer to avoid having to look for and manage the files, so I just

bring up the RDC, type in the computer name and go. Definitely worth browsing

the help file as well.

Once connected, you can stay connected as long as you want, just minimize the

window. To disconnect, you have two options. Do the start logoff which will

close your connection and end any task you had running, or just close the window

- which leaves the session running (and uses up 1 of the 2 possible connections

to the server). Leaving the session running makes sense if you're running an

interactive task like defrag, a long file copy, etc.

Occasionally all the available connections will be used up. If you have

Terminal Services Manager loaded you can easily close down a connection. If you

don't (the case on my XP machine at home),

Brian Knight

pointed out a very nice trick you can use if it's a SQL box. To get all the

active sessions, open Query Analyzer and run this:

master..XP_CMDSHELL 'QUERY SESSION'

You'll get back a resultset containing sessionname, username, id, and state.

Pick the ID of the connection you want to kill, then run this:

master..xp_cmdhell 'logoff sessionid'

If you get back a single row containing null, it worked and you should be

able to get a connection.

Got other tips and tricks that you use with Terminal Services? Are you using

it at work or opting for a different solution? Will be interesting to hear the

opinions on this one!

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating