How do I prevent lock screen of remote computer when remote RDP connection into the computer is started?

This question “Disable Lock Screen after Remote Desktop session in Windows 10” is for disconnecting so it didn't help.

This question "Remote desktop connection without locking the remote computer" was for Windows 7 and 8, the commands are not working for windows 10; all commands referenced in this question disconnects the rdp session. Additionally, there was no answer selected for that question as it does not supply a valid solution to the question.

Specifically, tscon %sessionname% /dest:console will disconnect the session.

  • 1
    Possible duplicate of Remote desktop connection without locking the remote computer
    – Tetsujin
    Aug 24, 2018 at 15:52
  • 2
    @Tetsujin updated - this is not a duplicate. Aug 24, 2018 at 16:22
  • 1
    It's a perfect duplicate - the other just had a get-out clause, 'can I restore as I disconnect?'. Without that get-out clause the answer is [from further down] "You can't".
    – Tetsujin
    Aug 24, 2018 at 16:27
  • @Tetsujin it would be a perfect duplicate if I was asking in the context of Windows 7. I am asking for Windows 10. Aug 24, 2018 at 16:33
  • Let's leave it to the community to decide. Mine is merely one vote, 5 are needed [or a mod]. The answer for Win10, btw, is still "you can't"
    – Tetsujin
    Aug 24, 2018 at 16:35

7 Answers 7


You purchase a license that allows you to run the RDP host as a terminal server. The reason the screen locks like this when using RDP is that consumer licenses of Windows allow no more than one active session at a time. The only reliable way around this that lets you continue to use RDP is to get the system licensed as a terminal server, which is expensive and may require an Enterprise or Education edition license.

Alternatively, there are multiple other options for remote access to a Windows system. If you only care about access from the local network, VNC is probably your best bet (unless you need the session to be encrypted). If you need offsite access, you can find a number of options for it online that not only don't involve RDP, but also give a nice visible indication that someone is remotely connected to the session (and often provide some kind of chat functionality for the local user to talk with the remote user).

  • Windows 10 Pro ok on remote?
    – Jonathan
    Oct 21, 2020 at 23:39

I found a solution in lieu of rebooting:

  1. Open Command Prompt, issuing query session to get the Session ID of RDP
  2. Paste the below content into %UserProfile%\Desktop\close.bat, replacing SessionId with the result of Step 1:
    echo off
    Tscon %SessionId% /Dest:console
  3. Run close.bat as Admin instead of disconnecting from the session
  • 6
    Please add more context, do I have to be connected already, and which machine is this run on?
    – Jonathan
    Oct 21, 2020 at 23:41
  • This works perfectly! Oct 4, 2022 at 23:12

Based on Urumanathan Palanivel's answer, following CloseRdp.cmd could be used;

    @echo off
    for /f "tokens=1,2,3 delims= " %%i in ('query session ^| findstr "Active"') do set SessionId=%%k
    Tscon %SessionId% /Dest:console
  • Awesome! This works great, even more useful having it scrape for the session ID. Oct 4, 2022 at 23:13

Based on subcoder's answer based on Uramanathan's answer, with additions from Duncan and Jimadine's comments, I created a scheduled task that runs when closing/disconnecting the RDP connection. It required a slight tweak to the findstr command to search for %USERNAME% instead of Active, because at the time of the triggering event, the session is already in the Disc state.

The task is triggered by the Microsoft-Windows-TerminalServices-LocalSessionManager/Operational event log getting a logoff event (EventID=24). Then it runs a simple command whenever a user logs off. The command gets the query session output which looks like:

SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
 services                                    0  Disc
>rdp-tcp#0         Matt                      2  Active
 console                                     5  Conn
 rdp-tcp                                 65536  Listen

It searches for %USERNAME% (in my case "Matt") and gets the ID column for that row. It passes the ID to the tscon command with %k /Dest:console, which unlocks the screen for the logged in user. This command probably only works if the user logging in remotely is the same user logged in locally, but I haven't tested.

Here's a task scheduler XML to import. The Author and UserId elements are removed and will be automatically filled in with your user when you import the task.

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
    <URI>\Unlock remote screen</URI>
      <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Microsoft-Windows-TerminalServices-LocalSessionManager/Operational"&gt;&lt;Select Path="Microsoft-Windows-TerminalServices-LocalSessionManager/Operational"&gt;*[System[Provider[@Name='Microsoft-Windows-TerminalServices-LocalSessionManager'] and (EventID=24)]]&lt;/Select&gt;&lt;Suppress Path="Microsoft-Windows-TerminalServices-LocalSessionManager/Operational"&gt;*[UserData[EventXML[Address="LOCAL"]]]&lt;/Suppress&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    <Principal id="Author">
  <Actions Context="Author">
      <Arguments>/C "for /F "tokens=1,2,3 delims= " %i in ('query session ^| findstr "%USERNAME%"') do tscon %k /Dest:console"</Arguments>
  • If by any chance anyone is running this on a Windows embedded system you'll find the task can't be imported, to fix, change the Task Version on line 2 to 1.2 and remove <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession> and <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine> from eh settings section.
    – Duncan
    Nov 2, 2022 at 10:13
  • You could even embed the commands in the XML, obviating the .cmd script: <Command>C:\Windows\System32\cmd.exe</Command> <Arguments>/C "for /F "tokens=1,2,3 delims= " %i in ('query session ^| findstr "%USERNAME%"') do tscon %k /Dest:console"</Arguments>
    – Jimadine
    Nov 14, 2022 at 10:55
  • 2
    I love how none of the 3 answers explain what's going on with these commands 😆
    – huyz
    Mar 31 at 13:31
  • 2
    Thanks Duncan and Jimadine for the ideas to improve it! I updated the answer accordingly and, even better, I found that the Author and UserId elements can be left out, in which case they will be filled in automatically upon importing! I added some explanation of how it works for huyz's edification. Apr 2 at 16:12
  • @MattChambers Thanks for the explanations!
    – huyz
    Apr 12 at 2:47

I don't know of a way to disable the lock screen specifically when an RDP session is connected.

You could perhaps run during the session the free utilities of Insomnia or Caffeine to fool Windows into believing that some activity is going on.

Alternatively, you could do Disable Windows 10 Lock Screen, although this will have an effect everywhere.

  • 1
    The screen locking isn't due to lack of local activity. Consumer Windows licenses only allow for at most one user session to be 'active' at a time. The screen locking when someone connects over RDP is Microsoft's way of enforcing this. Aug 24, 2018 at 19:17
  • 1
    This was since always a marketing decision by Microsoft to promote its costlier versions. There are hacks around it but they contradict the license.
    – harrymc
    Aug 24, 2018 at 19:55
  1. Name the file Something.ps1, pasting the below in it:
    param($minutes = 250) $myshell = New-object -com "Wscript.Shell" for ($i = 0; -lt $minutes; $i++) { Start-Sleep -seconds 120 $myshell.sendkeys(".") }
  2. Open notepad, and it will start filling with (.) after 120 seconds
  • 1
    Please explain how this answers the question.  Please do not respond in comments; edit your answer to make it clearer and more complete. Aug 10, 2019 at 1:10
  • 2
    The answer tries to send a key hit to remote periodically so that it looks like the remote desktop is being accessed by a human being. However I think it has a side effect that whatever key is selected, it's possible that key has a meaning for the current app in the remote desktop and thus causes an unexpected result. So I don't recommend this way.
    – Robert
    Aug 28, 2020 at 10:37

There is a way on consumer (Pro and Home) licences to not have the lock screen activated while connected via Remote Desktop.

Send out remote desktop invitations from the target machine instead of connecting directly.

This is not ideal for all uses, but it is ideal when helping someone remotely which is the only valid case when you also don’t want the lockscreen to get in the way.

One extra advantage of Remote Desktop invitations is the ability to connect to machines which don’t have a public IP address or port forwarding behind a NAT - which is basically any machine of anyone you want to help via Remote Desktop.

Search for “remote assistance” right in the Start Menu search then select “invite someone to connect to your PC”.

Alternatively run “msra” through the run dialog.

You will be able to assist someone through RDP without dumping them into the lock screen while you work. They will also be able to see what you’re doing - also if they move the mouse or type they will lock your controls out temporarily which is also great when collaborating.

Here are some detailed steps: https://support.microsoft.com/en-us/windows/solve-pc-problems-remotely-with-remote-assistance-and-easy-connect-cf384ff4-6269-d86e-bcfe-92d72ed55922

The above is also the preferred way Microsoft or other organizations offer assistance remotely and it comes preinstalled with any Windows machine (no need for installing extra software).

You must log in to answer this question.

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