Way back in 2007, I wrote this post, which details how to get a Windows XP computer to return to the desktop (console) at the conclusion of an RDP session.
Microsoft’s client operating systems only support one session at a time, meaning that you can have a standard “desktop” session with your Windows PC, or you can connect via Remote Desktop for a remote session. But you can’t do both at once. And when you connect via Remote Desktop, the desktop (console) session is locked, and will remain locked after you log off, until the console user unlocks it via the keyboard.
Needless to say, this is a pain for remote support of Windows users. Normally, I’d have to log in via Remote Desktop, do what I had to do to fix it, then call the end user and tell them that I was done. They’d then unlock their computer and go about their business. But the article I posted in 2007 shows you how to create a shortcut that disconnects the remote user and unlocks the screen, so the end user knows that he or she can use their computer again.
Unfortunately, the batch file from the 2007 post doesn’t work with Windows 7. Microsoft apparently changed the way TSCON works, rendering the old batch file useless. But fear not: I’ve finally figured out how to make it work in Windows 7! Just copy and paste the text below into your favorite text editor (I prefer Notepad++) and save the file with the extension .BAT or .CMD:
tscon.exe 1 /dest:console
Here’s the critical thing: when you’re connected remotely and want to return the user to the desktop session, right-click the batch file and choose “Run as Administrator”. A UAC prompt will appear; click “Yes” and your RDP session will end, and the console session will be unlocked on the remote computer.