Enable user to kill their own RD session

Little Debbie 1 Reputation point
2021-02-18T16:29:22.477+00:00

We have a Windows Server 2012 / Windows 10 client domain environment. Our terminal server has various Remote Apps published and deployed to the end users machines.

Sometimes a user's session freezes up and it needs forcefully disconnected, because simply closing the window and re-launching the remote app will just resume their frozen session.

So, we will log into the terminal server, open task manager, find the user, right click and Logoff to force kill their session.

I'd like to know if there is a script the users themselves can run to perform this same action...force kill their own Remote app session. This will free up our time and the user's time if they can just do it themselves.

I've been trying to come up with something using qwinsta, but whatever I try will not work.

I was thinking I need to query the sessions on the terminal server (Server-TS)....somehow match the session with the current logged on user for that computer (perhaps %username% would work?)...funnel that session information to a variable...and then use some kind of kill/disconnect command to force close it.

Again, the goal is to allow a user on their own workstation the ability to force kill their own Remote App sessions so that an administrator doesn't have to log into the terminal server, go into task manager, etc etc. each time an app freezes or glitches up.

Any help would be greatly appreciated!!!

Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,332 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,430 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Eleven Yu (Shanghai Wicresoft Co,.Ltd.) 10,706 Reputation points Microsoft Vendor
    2021-02-19T05:10:23.597+00:00

    Hi,

    I was thinking I need to query the sessions on the terminal server (Server-TS)....somehow match the session with the current logged on user for that computer (perhaps %username% would work?)...funnel that session information to a variable...and then use some kind of kill/disconnect command to force close it.

    What you were thinking should be right. I have done a lab test and running below commands in my test environment can successfully kill the user's remote session from the client side.

    1. run qwinsta /server:servername to get the remote session id which matches the logged on user name.
    2. run rwinsta /server:servername session ID to kill the session

    Please kindly have a try in your environment. If it does not work, please share the error message you get.

    Thanks,

    Eleven

    If the Answer is helpful, please click "Accept Answer" and upvote it. Thanks.


  2. AStaUK 21 Reputation points
    2021-03-08T11:37:24.877+00:00

    A little late, why not just use CTRL+ALT+END from within the RemoteApp the user should then be able to sign out.

    0 comments No comments