46

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?

yossis
  • 572

14 Answers14

22

Just run this from a remote session:

tscon %sessionname% /dest:console
Braiam
  • 4,777
Ryan
  • 303
  • 3
  • 10
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
Felix
  • 241
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.

SIRS
  • 235
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.

raven
  • 5,435
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

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.

NotTheDr01ds
  • 28,025
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.

techturtle
  • 9,376
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/

Nicu Zecheru
  • 5,572
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

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.

Mike K
  • 89
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)

DaveC
  • 1