Is there any script to configure the automatic unlock screen? I want to call the automatic unlock screen after the remote desktop is finished

Sheng Ji 0 Reputation points
2024-09-18T00:54:25.2733333+00:00

The effect I want to achieve is that the remote desktop does not lock the screen after exiting use, and the current idea is to achieve by unlocking the screen script, but there is no such script. Whether there are other ways to achieve, welcome to communicate

for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (%windir%\System32\tscon.exe %%s /dest:console)

The above script can only be active call implementation, I want to achieve passive

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,718 questions
Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
5,498 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,228 questions
Remote Desktop
Remote Desktop
A Microsoft app that connects remotely to computers and to virtual apps and desktops.
4,604 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. S.Sengupta 19,661 Reputation points MVP
    2024-09-18T01:37:31.81+00:00

    To do this create a custom script or use system-specific tools.

    You may configure a PowerShell script or, use the tsdiscon.exe command to disconnect from the session and lock the screen. To do this make a batch file.

    https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/tsdiscon

    @echo off

    tsdiscon

    timeout /t 3 /nobreak

    rundll32.exe user32.dll,LockWorkStation


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.