This quick script ends your current RDP session and returns your PC to the console.
I’ve needed this a couple of times now, and they were both Steam-related! (plus not wanting to walk to the remote PC all the time! 🙂
Enter this in a bath file “logoff.bat” or similar –
set MY_SESSION_ID=unknown
for /f “tokens=3-4” %%a in (‘query session %username%’) do @if “%%b”==”Active” set MY_SESSION_ID=%%a
C:\Windows\System32\tscon.exe %MY_SESSION_ID% /dest:console /v
Run that batch file as an admistrator, whilst in an RDP session, and it will end your current RDP session returning your PC to the console!
I had to walk to that PC a lot of times!!
Sources –
https://steamcommunity.com/groups/homestream/discussions/0/540732889170346271/
https://superuser.com/questions/303927/how-can-i-retrieve-the-session-id-from-command-line