How To Unlock Desktop Screen After Remote Access Disconnected

0

Remote Desktop to VM on AWS to check out, investigate issues, deploy things are very common, especially when you are in CI/CD, Agile, DevOps environment. The demand to unlock desktop screen remotely is crucial for automation tests to run. A friend of mine says he struggled with this for 2 weeks. Therefore I am going to put simple and short answer right below.

How To Unlock Desktop Screen Remotely

Please note that you need to run these commands with administrative rights.

Below command should work for Windows 7, Windows 8, Windows 8.1, Windows 10

tscon [RDC Session ID] /dest:console
Ex. tscon 1 /dest:console

Session ID can be retrieve by issuing below command

query session

Or simply use below single command

for /f “skip=1 tokens=3” %s in (‘query user %USERNAME%’) do (%windir%\System32\tscon.exe %s /dest:console)

Bonus

Below command should work on Windows Server

tscon %sessionname% /dest:console

If you have PowerShell installed on your remote machine, try this one

tscon ((quser $env:_TFSLab | select -Skip 1) -split ‘\s+’)[2] /dest:console

Wrapping Up

That’s it. It’s simple when you know it and it can take you weeks if you don’t (like my friend’s case). Please share if you have any inputs or comment if these work for you.

References:

Share.

About Author

A QA guy who is trying to learn some dev's skills as well as English by blogging his development notes in English. Hey, please let me know if you see any spelling mistake or I should write things in another better way.