How can I restore a remote desktop session to the local console?

  1. Create a desktop shortcut by right clicking on the desktop and selecting new, then select shortcut.
  2. In the text field enter:

    %windir%\System32\tscon.exe 0 /dest:console (See below)

  3. Right click the newly created shortcut, click properties.
  4. Click the shortcut tab, and click the Advanced button.
  5. Check the "Run as administrator" box and click OK.

If this doesn't work, try changing the number zero (tscon.exe 0 /dest...) in step 2 to the number one, and if it doesn't work, keep incrementing it until your remote desktop is released.

Alternately, open up a shell with start menu, run, cmd. Type qwinsta Enter, and look for the ID of the session that is in the active state (it will have a > character at the start of its session name). That's the number you need to use in step 2.

When you want to restore the console desktop, just double click on the shortcut and allow the administrator access.


Here's a version which avoids the dependency on GNU tools. It uses findstr, which is shipped with Windows.

for /f %%i in ('qwinsta ^| findstr /C:">rdp-tcp#"') do set RDP_SESSION=%%i
:: Strip the >
set RDP_SESSION=%RDP_SESSION:>=%
tscon %RDP_SESSION% /dest:console

glenviewjeff's answer got me most of the way there, but the session id is not always 1. If you try to disconnect the listening or console session like this you'll get an "Error 7045" - requested session access is denied, or if the session id doesn't exist a SessionID not found error.

I made a small batch file to pull out the current session. As I did this on Windows XP I needed to qwinsta rather than query session to figure out the current ID. This batch file uses unix command line utilities, I use Gnu on Windows (https://github.com/bmatzelle/gow/downloads) to have access to these. It pulls out the current session by searching for a ">" sign and then reassigns it back to the console session.

for /f %%i in ('qwinsta ^| grep "^>" ^| awk "{print $4}"') do set VAR=%%i
tscon %var% /dest:console

I needed this for a machine that is connected to a Fujitsu IX500 scanner, the scanner only scans if the screen is not on the user name / signon selection screen in Windows which is what you get when you log off or disconnect a session normally. As the machine runs without a screen I want to be able to connect via rdp, but if I did that I couldn't use the hardware scan button until I logged in manually or restarted. The batch file above solves this problem.