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.
6 Answers
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).
1I found a solution in lieu of rebooting:
- Open Command Prompt, issuing
query sessionto get theSession IDofRDP - Paste the below content into
%UserProfile%\Desktop\close.bat, replacingSessionIdwith the result of Step 1:echo off Tscon %SessionId% /Dest:console - Run
close.batas Admin instead of disconnecting from the session
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 Based on subcoder's answer based on Uramanathan's answer, I created a scheduled task that runs when closing/disconnecting the RDP connection. It required a slight tweak to the CloseRdp.cmd to user %USERPROFILE% instead of Active, because at the time of the triggering event, the session is already in the Disc state:
@echo off
for /f "tokens=1,2,3 delims= " %%i in ('query session ^| findstr "%USERNAME%"') do set SessionId=%%k
Tscon %SessionId% /Dest:consoleHere's a task scheduler XML to import. Adjust the Author, UserId, and path to CloseRdp.cmd as necessary.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns=""> <RegistrationInfo> <Date>2022-02-10T11:17:45.9347484</Date> <Author>COMPUTER\User</Author> <URI>\Unlock remote screen</URI> </RegistrationInfo> <Triggers> <EventTrigger> <Enabled>true</Enabled> <Subscription><QueryList><Query Path="Microsoft-Windows-TerminalServices-LocalSessionManager/Operational"><Select Path="Microsoft-Windows-TerminalServices-LocalSessionManager/Operational">*[System[Provider[@Name='Microsoft-Windows-TerminalServices-LocalSessionManager'] and (EventID=24)]]</Select><Suppress Path="Microsoft-Windows-TerminalServices-LocalSessionManager/Operational">*[UserData[EventXML[Address="LOCAL"]]]</Suppress></Query></QueryList></Subscription> </EventTrigger> </Triggers> <Principals> <Principal> <UserId>S-1-5-00-230802483-4141366015-587266008-0000</UserId> <LogonType>InteractiveToken</LogonType> <RunLevel>HighestAvailable</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>Parallel</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession> <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>PT1H</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>%USERPROFILE%\CloseRdp.cmd</Command> <WorkingDirectory>%USERPROFILE%</WorkingDirectory> </Exec> </Actions>
</Task> 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 ofInsomniaorCaffeineto fool Windows into believing that some activity is going on.
Alternatively, you could doDisable Windows 10 Lock Screen, although this will have an effect everywhere.
2- 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(".") } - Open
notepad, and it will start filling with(.)after 120 seconds