How to automatically restore the previous session when logging off RDP

Microsoft’s Remote Desktop Protocol (RDP) for remote controlling a computer has some decent features, but there’s one feature I’m not a big fan of. When you start a RDP session, it locks the current user out, leaving you having to manually log back in on the physical computer in order to get proper access to the computer again. This is a security feature that makes sense in some cases, but not if the computer you control is in a locked room all day, and you just want to leave it as you found it at the end of your RDP session.

There’s no option to disable this “feature” in RDP itself, but you can easily get around it using a simple command that kicks out the RDP user and restores the previous session. For Windows 7 (I haven’t tested other versions of Windows) this command is:

call %windir%\system32\tscon.exe 1 /dest:console

If you want this as a clickable file, you can put it in a .bat file. The way you do this is to open Notepad, and then paste it in. Select “Save as”, change filetype to “All files”, and save it as “logout.bat” (or something else that ends in .bat). Now, when you double click that file, the command executes.

You might end up trying to pin this to the Windows task bar, and quickly realize that Windows won’t let you. The way to get around this is to do the following:

  • Create a shortcut to the .bat file.
  • Create yet another shortcut, but manually specify the location for this one. It needs to be a shortcut to explorer.exe, with an extra attribute that points to the shortcut to the .bat file. In my case, the contents of the second shortcut reads:

C:\Windows\explorer.exe “D:\logout – Shortcut.lnk”

Your paths and file name might be different.

  • Optional: Go into the preferences for the second shortcut and give it a nice icon. I use the system power off icon.
  • Add the second shortcut to the task bar

This is a workaround that actually allows you to put a .bat file on the task bar, something that Windows in its infinite wisdom doesn’t allow you to do by default. It makes it work by adding a shortcut to explorer.exe, which it tells to open a file, which happens to be a shortcut that points to the bat file. Now you just have to use this new task bar button (or the loose file, your choice) to log off RDP instead of the usual method, and your previous session will be restored in the process! It ain’t pretty, but it works!

I use this trick to give me a task bar button to click to log off Jump Desktop on my iPad and restore my desktop computer to how it was before I logged in. Not only does this save me from having to manually unlock the computer when I come home, but it also allows me to continue using other apps that talk to software on my computer, which is disabled when the local user is kicked off.

Pocketables does not accept targeted advertising, phony guest posts, paid reviews, etc. Help us keep this way with support on Patreon!

Andreas Ødegård

Andreas Ødegård is more interested in aftermarket (and user created) software and hardware than chasing the latest gadgets and tends to stick with his choice of device for a long time as a result of that. After a five year break from writing, he's back to share this view with the world once again.