45

Is it possible to connect via Remote Desktop Connection to a windows 7 machine without locking the remote computer (I want to use the same logged in user)? Or is it possible to release the lock after the remote desktop session is closed?

0

14 Answers 14

20

Just run this from a remote session:

tscon %sessionname% /dest:console
5
  • 1
    Get the error Sessionname %sessionname% not found, any ideas? Guess it is not defined under Windows 8
    – Felix
    Oct 27, 2013 at 11:06
  • Not sure about Windows 8, this worked for Windows 7.
    – Ryan
    Oct 28, 2013 at 18:56
  • 4
    @phil I got that 'error' from his ans on 7 too. Apparently social.technet.microsoft.com/Forums/windows/en-US/… For XP: tscon 0 /dest:console For 7: tscon 1 /dest:console <-- run on the remote machine. BUT.. this is just so that when the client(mstsc.exe) computer disconnects from the comp it is viewing, then it won't lock. So you disconnect by running that command on the comp you are viewing. But that method won't stop it locking the screen when you log in.
    – barlop
    Jun 6, 2014 at 9:26
  • 3
    %sessionname% isn't available from an elevated (administrator) command prompt, presumably because windows treats the admin prompt as a separate non remote session. However tscon.exe requires admin rights to end a session. The solution is to use the above command in a shortcut and to select "run as administator" in the advanced options (also works if you point a "run as administator" shortcut to a batch file with the necessary command and pass %sessionname% to the elevated batch file as an argument. I use this to disconnect without locking and suspend the PC at the same time)
    – Jules
    Jan 2, 2018 at 20:04
  • This does not keep the screen unlocked while the remote session is active. So you can't let the user sitting in front of the computer see the remote user's activity.
    – Dojo
    Sep 15, 2022 at 20:07
10

You can use this PowerShell script, which also supports Windows 8:

$server   = 'MyServer'
$username = $env:USERNAME

$session = ((quser /server:$server | ? { $_ -match $username }) -split ' +')[2]

tscon $session /dest:console
3
  • This didn't work for me at all. I just get "access is denied." It seems like it is trying to match the session on the other end with your local username? But I want to connect to the console session, which could be logged in as a different user.
    – Dan
    Jan 6, 2016 at 18:13
  • @Dan So why are you using the $env:USERNAME if you don't want to use it? Use the username you want to use instead. You should always think while copy&pasting anything. It may cause you pretty bad times if you just execute everything you find somewhere. Apr 20, 2016 at 15:12
  • @Dawid. Um, thanks? I looked at the script and it is pretty harmless. I chose to run it, wondering how it could work. Turns out, it doesn't. So I made a note of that. Bottom line is the script doesn't specify what situations it works in (probably domain user logged on as the same user on that machine). I did try it with a different username, but that didn't work either.
    – Dan
    Apr 26, 2016 at 19:10
8

run cmd on remote computer, then run this command query session you will see something like this

 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
 services                                    0  Disc
>console           SIRS                      1  Active
 rdp-tcp                                 65537  Listen

then run this command tscon x /dest:console where x is your active session ID, which 1 in my case.

6

refer to https://techjourney.net/remote-desktop-connection-without-locking-remote-computer-session-on-disconnect/

If you need to unlock the remote computer after closing the Remote Desktop Connection, here’s a trick which you can use to force RDP to disconnect without locking the session and logged local user back in on the local console screen upon disconnection of Remote Desktop Connection.

On the remote system connected through RDC (not on your computer which RDC is initialized to connect to remote system), open a Command Prompt window as administrator, then run the command depending on the Windows operating system that is running on the remote system.

On Windows XP:

tscon 0 /dest:console

On Windows Vista, Windows 7, Windows 8, Windows 8.1, Windows 10 or newer:

tscon 1 /dest:console

On Windows Server:

tscon %sessionname% /dest:console

No Locking Local Console when Using Remote Desktop Connection

5

As far as I know, it's not possible to prevent Remote Desktop Connection from locking the computer, but Ultra VNC allows you to remote control another machine without locking it.

2
  • 5
    Ultra VNC is much slower which prevents me from using it
    – yossis
    Dec 8, 2009 at 21:46
  • It IS possible... see Felix's answer
    – JoelFan
    Aug 12, 2015 at 15:16
3

Take a look at remote assistance. It basically uses the same remote desktop technology under the hood.

You go into the help and support area and create a remote assistance request you can send to the person you want to remote at the same time.

Alternatively you could use Logmein.com and install LogmeinFree which enables you to remote control a users pc at the same time they;re using it.

1
  • 6
    Remote assistance requires renewing the ticket, no?
    – yossis
    Dec 8, 2009 at 21:47
1

As an alternative you can use Gbridge: "Gbridge is a free software that lets you remotely control PCs, sync folders, share files, and chat securely and easily. An extention of Google's gtalk service, Gbridge automatically forms a collaborative, encrypted VPN (Virtual Private Network) that connects your computers and your friends' computers directly and securely. Gbridge has many unique features." http://www.gbridge.com/

1

It can't be done with RDC itself, you'll need to use a third party tool like TeamViewer. You technically can use remote assistance, but once you're out of requests you can't do anything.

1
  • TeamViewer looks like a nice app, but I just tested it and it's not completely free and much slower than remote desktop (even when used in a LAN)
    – yossis
    Dec 8, 2009 at 22:35
1

Honestly, I would just use RealVNC, I feel its the best remote desktop tool out there. Its very fast, dont get any of the lag with UltraVNC. RealVNC is also excellent when remoting in your computer from outside your house.

2
  • 3
    As much as I'd like to recommend RealVNC (or any VNC for that matter), I can't (despite having been a very early user of it). RD connections feel much more responsive, especially over bandwidth constrained links. Dec 8, 2009 at 16:19
  • This was my experience also. Remote desktop is much faster, and I yet to find other alternatives (in terms of performance)
    – yossis
    Dec 8, 2009 at 21:50
1

Mentioned in another answer, but LogMeIn.com has a free version, and allows you to share the connection with the local user or blank the screen. I have found the response time fairly decent over slower connections, but the graphics quality goes down when speed does.

1

Please note, this process is designed to leave the the desktop in an unlocked, and thus insecure, state. It should not be used if an untrusted third-party might have physical access to the system while the user is not present.

I ran across this issue (and question) because I commonly connect to my desktop machine from my laptop using RDP. I'm actually doing so right now when typing this answer, since I keep my "main" browser session on my desktop. When I tried connecting Moonlight, an open-source nVidia Gamestream client, I found that RDP was locking the system when exiting. This is good behavior, of course, but GameStream requires that the desktop not be locked.

While there are a lot of answers here already, some of them dating back almost a dozen years, my preference on how to solve it in 2021 on Windows 10 comes down to what I consider a "simpler" PowerShell one-liner:

Start-Process tscon -ArgumentList ((quser | Select-Object -skip 1) -replace ".* (\d+) .*", '$1'), "/dest:console" -Verb RunAs

This builds on Felix's answer:

  • It first runs quser to get the session ID. On a single-user, Windows 10 Professional system, there should only be one session. However, the ID will change if you connect often, so you need to retrieve that via the RegEx -replace, which finds the first "number" on the line. Unless the username itself is purely a number, then this should work in all other cases.

  • It runs tscon ... /dest:console to disconnect that session using the result of the quser RegEx.

  • It does so using Start-Process ... -Verb RunAs to run the command elevated with Admin permissions, which is necessary on Windows 10, at least. Given the lack of mention of this in previous answers, it might not have been needed on Windows 8 or before.

2
  • This seems to log me out of my RDP session :/
    – Jonathan
    May 20, 2021 at 20:29
  • @Jonathan Does it really "log you out"? It should disconnect you from your RDP session, yes, but your user should still be logged in and all apps running on the desktop. All of these tscon ... /dest:console answers should have that same result, as that's the goal of the question (at least the second half of it) -- "is it possible to release the lock after the remote desktop session is closed?" This one-liner disconnects from an RDP session without locking the screen. May 21, 2021 at 5:48
0

To solve a similar Task where we had to prevent Screen-lock for a Schedule Task, I've written a Batch File which looks like this:

for /f "tokens=3-4" %%a in ('query session %username%') do @if "%%b"=="Active" set RDP_SESSION=%%a
tscon %RDP_SESSION% /dest:console

This also requires Admin Rights for execution but it's pretty handy as a shortcut on the user's desktop.

0
for /f "tokens=4 delims= " %%G in ('tasklist /FI "IMAGENAME eq tasklist.exe" /NH') do tscon %%G /dest:console

Tested on Windows 10. Batch file format

-2

This only addresses one half of the initial question: is it possible to release the lock after the remote desktop session is closed?

My approach quite simple: within the remote desktop session, do Alt-F4 until all windows are closed, then do Alt-F4 one more time and select 'Sign Out' (as opposed to 'Disconnect', which is also offered as an option). Other users will then be able to sign in (without kicking you out first, because you properly signed out)

3
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jan 7, 2022 at 23:13
  • And after that the remote computer isn't locked anymore so a local user can continue work without typing a password? Are you sure? (That's what TS is asking)
    – Rik
    Jan 8, 2022 at 0:13
  • Possibly I misunderstood the spirit of the question - After that, a local user won't be able to continue work without typing a password. But they will be able to sign-in (with a password) because the remote PC won't be locked.
    – DaveC
    Jan 8, 2022 at 23:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .