Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

After I am finished with a remote desktop connection, I'd like to be able to restore the remote desktop to the local console so that the user doesn't have to re-enter the password and log back in.

How can I create a desktop shortcut to do this?

share|improve this question
add comment

3 Answers 3

up vote 4 down vote accepted
  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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

I couldn't get Simon D's batch file command to work. This is what worked for me on Windows 7 x64:

for /f %%i in ('qwinsta ^| grep "^>" ^| awk "{print $3}"') do tscon %%i /dest:console
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.