Logo Neurocoda

Keep Windows Server RDP Session Active After Disconnect

Neurocoda
Neurocoda
2026-07-03 12:46:35 71 Words 1 Min ...

Create a text file and enter the following content:

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

Change the file extension to .exe. Pin it to the taskbar. Each time you want to disconnect, click this file (it will keep the session running).

Navigate to the following path:

%userprofile%\\AppData\\Roaming\\Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar

Change the shortcut’s target file back to .bat extension and the source file’s extension back to .bat. Finally, remember to set it to run with administrator privileges in advanced settings.

Source:
Disconnecting From Remote Desktop While Running Automated Tests | TestComplete Documentation

Title: Keep Windows Server RDP Session Active After Disconnect Author: Neurocoda Created at: 2026-07-03 12:46:35 Link: https://neurocoda.com/en/posts/keep-windows-server-rdp-session-active-after-disconnect-en/ License: This work is licensed under CC BY-ND 4.0.

Comments