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.
- run qwinsta /server:servername to get the remote session id which matches the logged on user name.
- 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.