Question

I am trying to automate some authentication where I connect via RDP, and authenticate with a particular server, using credentials taken from a PROPERTIES file.

On windows, the built in RDP client is mstsc.exe, but it doesnt seem like you can supply login credentials via command line, like on linux and Mac.

Is there any workaround on Windows, using mstsc.exe, where I can authenticate automatically, without any interaction from the user?

Thanks.

Was it helpful?

Solution

Could you use a custom connection file ? Then pass it into MSTSC E.G:

mstsc customfile.RDP

Here's what a RDP file looks like, I saved credentials, note the FULL ADDRESS field and the USERNAME field.

 screen mode id:i:2
use multimon:i:0
desktopwidth:i:1680
desktopheight:i:1050
session bpp:i:32
winposstr:s:0,3,0,0,800,600
compression:i:1
keyboardhook:i:2
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:2
displayconnectionbar:i:1
disable wallpaper:i:1
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:###.###.###.###:####
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
redirectdirectx:i:1
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:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
use redirection server name:i:0
username:s:<USERNAME>

pass that to the mstsc.exe call. I'll try and see where the password is stored.

I wouldn't call this super secure either. I think the password is stored encrypted, it'll be a few minutes until I figure out how.

What are you trying to accomplish exactly? MSTSC doesn't return values based on authentication. So, I'm not sure what you plan on capturing.

OTHER TIPS

You can store the RDP credentials using the cmdkey tool

    cmdkey.exe /generic:servername /user:username /pass:pass

Once you have run this, your mstsc call will be able to auto login:

    mstsc.exe /v:servername
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top