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.





