Skip to content

Instantly share code, notes, and snippets.

@cybersholt
Created December 30, 2023 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cybersholt/e818316d2253e5d0b477b2dde786d0a5 to your computer and use it in GitHub Desktop.
Save cybersholt/e818316d2253e5d0b477b2dde786d0a5 to your computer and use it in GitHub Desktop.
RDP Keep Session Active + fix DPI issue
@echo off
:: Get current user's session ID
for /f "tokens=1,2,3 delims= " %%i in ('query session ^| findstr "%USERNAME%"') do set SessionId=%%k
:: Reconnect the session to the console
Tscon %SessionId% /Dest:console
:: Restart Windows Explorer
taskkill /f /im explorer.exe
start explorer.exe
:: Load a predefined DisplayFusion Monitor Profile
"C:\Program Files (x86)\DisplayFusion\DisplayFusionCommand.exe" -monitorloadprofile "default_with_90_right"
:: Optional: Add additional commands if needed
:: End of script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment