Skip to content

Instantly share code, notes, and snippets.

@noelbundick
Created December 17, 2019 17:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelbundick/58cbfbd8d32aa8c881276a36ca3b46e0 to your computer and use it in GitHub Desktop.
Save noelbundick/58cbfbd8d32aa8c881276a36ca3b46e0 to your computer and use it in GitHub Desktop.
RDP from WSL

This was an experiment in WSL interop from way back in May 2018. My goal was to be able to type noel-pc123 from a bash terminal and immediately launch into an RDP session. Should still work!

msrdp-template.rdp

  • This file is used with mstsc.exe to launch a remote desktop session
  • This file must be encoded as UTF-16
  • Replace the following values with your own:
    • DOMAIN\user: the credentials you will use for your connection
    • mygateway.example.com: the gateway server used for your connection (if unused - just remove the whole line)
screen mode id:i:2
use multimon:i:1
desktopwidth:i:2560
desktopheight:i:1440
session bpp:i:32
winposstr:s:0,3,0,0,800,600
compression:i:1
keyboardhook:i:0
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:7
networkautodetect:i:1
bandwidthautodetect:i:1
displayconnectionbar:i:1
username:s:DOMAIN\user
enableworkspacereconnect:i:0
disable wallpaper:i:0
allow font smoothing:i:0
allow desktop composition:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:COMPUTER_FQDN
audiomode:i:2
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
drivestoredirect:s:
autoreconnection enabled:i:1
authentication level:i:2
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:mygateway.example.com
gatewayusagemethod:i:2
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:1
promptcredentialonce:i:1
gatewaybrokeringtype:i:0
use redirection server name:i:0
rdgiskdcproxy:i:0
kdcproxyname:s:
function msrdp() {
WIN_TEMP=`cmd.exe /c echo %TEMP% | sed --expression='s/\r//g;s/\\\/\\\\\\\/g'`
WIN_TEMP=`wslpath -u $WIN_TEMP`
RDP_PATH="$WIN_TEMP/$1.rdp"
iconv -f utf-16 -t us-ascii < msrdp-template.rdp | \
sed "s/COMPUTER_FQDN/$1/g" | \
iconv -f us-ascii -t utf-16 \
> $RDP_PATH
WIN_RDP_PATH=`wslpath -w $RDP_PATH | sed --expression='s/\\\/\\\\\\\/g'`
mstsc.exe $WIN_RDP_PATH
}
alias noel-pc123="msrdp noel-pc123.corp.example.com 2&>1 & disown"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment