Q. How can I disconnect a Terminal Services (TS) RemoteApp session instead of closing the application?

A. Normally, when you close a TS RemoteApp, you simply close the application window, which stops the application’s process on the terminal server. If no other applications are running in the session, the Terminal Server then disconnects and logs off the session that was hosting the RemoteApp. Using the TS RemoteApp environment, there is no way to disconnect from an application without closing it.

The best way I’ve found to disconnect the session is by using the Tsdiscon command. To use the command you first need to find your session number using the Query session command. For example, I am running a TS RemoteApp on the server savdalts01. I can query all the sessions on that server, by using the following command:

C:\Users\john>query session /server:savdalts01

The command’s output is this:

SESSIONNAME        USERNAME     ID    STATE     TYPE DEVICE<br>services                        0     Disc<br>console                         1     Conn<br>rdp-tcp#1          john         2     Active    rdpwd<br>rdp-tcp#0          savadmin     5     Active    rdpwd<br>rdp-tcp                     65536     Listen

From the output, I see that my session is session 2. I can force a disconnect from that session by running the following Tsdiscon command:

C:\Users\john>tsdiscon 2 /server:savdalts01

Next time I launch a TS RemoteApp on the server, the application will open again, with its state maintained.

Discuss this Article 2

pchicociv
on Nov 24, 2010
I am migrating a system from ws2003 to ws2008 in which users were able to open one application inside the Terminal Server Web Access, disconnect at any time and reconnect from any intranet computer through an intraweb. Now, with RemoteApp, I can mirror that behaviour, BUT (big but) I cannot disconnect-reconnect. As you say, tsdiscon is the best way to disconnect. Is there any possible way to reconnect to a session given its session id?
To connect for the first time, i generate an rdp file on the fly in the web server and send it to the client, which will open it and see the remoteapp. It is a system requirement that users can turn their computers off while long calculations continue working in the server.

Hope that you have any idea. Many thanks in advance and congratulations for your article.
Pedro Chico.
sheid75
on Sep 30, 2010
Since RemoteApp is running on top of terminal services, with the remote application in focus, you can press Ctrl-Alt-End to bring up the remote system's Ctrl-Alt-Delete page. If you close the RemoteApp window here, it will give you the disconnect warning the same as a full desktop session.

Please or Register to post comments.

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottYou'll have the opportunity to experience:
• The Microsoft
Technology Roadmap
• Office 365 Implementation
• Hyper-V Optimizing
• Windows 8 Deployment
and much more!

Come See Paul Thurrott & Rod Trent in Person!

Early Registration Now Open

Upcoming Training

Mastering System Center 2012

During over 6 hours of training you can join John Savill from your computer as he will walk you through the key components and capabilities of System Center 2012, what’s involved in using the components, and the benefit they can bring to your environment.

Register Now

Current Issue

May 2013 - The NameTranslate object is useful when you need to translate Active Directory object names between different formats, but it's awkward to use from PowerShell. Here's a PowerShell script that eliminates the awkwardness.

CURRENT ISSUE / ARCHIVE / SUBSCRIBE

Windows Forums

Get answers to questions, share tips, and engage with the Windows Community in our Forums.