Solved

Remote Desktop Client CLI RDP Gateway

Posted on 2014-01-18
11
1,082 Views
Last Modified: 2014-01-19
Is it possible to open an RDP session from the command line when an RDP gateway need to be specified? The standard command line options are available, I know. Server address, display width and height but I can't find clear how-to's involving RDP gateway. If I open a configured .rdp file with notepad I can see all my configured options including the gateway server but how to i place them in a windows command shell?
I'd like to put all the options below in a command shell or at least the credentials and gateway of course.

winposstr:s:0,1,0,0,1440,900
session bpp:i:32
full address:s:Server
compression:i:1
keyboardhook:i:0
audiomode:i:0
drivestoredirect:s:
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:0
redirectclipboard:i:1
redirectposdevices:i:0
displayconnectionbar:i:1
autoreconnection enabled:i:1
networkautodetect:i:0
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
username:s:
domain:s:
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
disable cursor setting:i:0
connect to console:i:0
administrative session:i:0
disable wallpaper:i:1
disable full window drag:i:0
allow desktop composition:i:0
allow font smoothing:i:0
disable menu anims:i:0
disable themes:i:1
bitmapcachepersistenable:i:1
BBarPinned:i:1
gatewaycredentialssource:i:4
gatewayhostname:s:remote.gateway-server-address.com
gatewayprofileusagemethod:i:1
gatewayusagemethod:i:1
promptcredentialonce:i:1
smart sizing:i:1
use multimon:i:0
videoplaybackmode:i:0
audiocapturemode:i:0
redirectdirectx:i:0
bandwidthautodetect:i:1

Open in new window

0
Comment
Question by:finkeltron
  • 5
  • 4
11 Comments
 
LVL 68

Expert Comment

by:Qlemo
ID: 39792458
The credentials aren't stored completely in the RDP file, that much should be obvious.

The question is - what do you try to accomplish? As you said, you can't provide most of the options on commandline, which is by design.
If you are working with many different RDP targets on a single PC, the best approach is to set up one RDP file per connection.
If you need that to be transferrable - no way. The password cannot be stored. Anything else can be done via a batch file, by assembling a RDP file. Since the options aren't required to be in a particular order, you can use a RDP template containing all or the common lines, and the batch will just append some options, either on the fly or persistent by keeping the RDP file as generated.
Anything of that fitting into your requirements?
0
 

Author Comment

by:finkeltron
ID: 39792471
To reduce down to my most important requirement, then scale from there, I primarily need to place a gateway address in the command line. All my hosts are behind a Windows Server Remote Desktop Gateway.RDC Gateway
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 39792487
For a single, fixed (and unconditional) RD gateway:
@echo off
setlocal EnableDelayedExpansion
(for /F "tokens=1,2* delims=:" %%A in (C:\Temp\EE\Template.RDP) do (
  set line=%%A:%%B:%%C
  if [%%A] == [gatewayhostname] set line=%%A:%%B:remote.gateway-server-address.com
  if [%%A] == [gatewayusagemethod] set line=%%A:%%B:1
  echo,!line!
)) > C:\Temp\EE\Target.RDP

Open in new window

The much easier option is to remove all lines changing from the template, and just append those needed:
@echo off
(type c:\temp\EE\Template.RDP
 echo gatewayhostname:s:remote.gateway-server-address.com
 echo gatewayusagemethod:i:1
) > C:\Temp\EE\Target.RDP

Open in new window

0
 

Author Comment

by:finkeltron
ID: 39792524
How do i place all that in a single line? It is going to be run from Windows CLI after all. I know it should start after c:\mstsc.exe /
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 68

Expert Comment

by:Qlemo
ID: 39792534
You won't be able to do that in a single line, you'll need to store the code in a batch file, and call it, optionally with some parameters for the RD gateway name to use and the like.
E.g. you store above into C:\Temp\EE\RDP-GW.cmd, slightly modified by adding
  mstsc C:\Temp\EE\Target.rdp /v:%1
as very last line. Then you call that batch as
  C:\Temp\EE\RDP-GW.cmd YourHostHere
0
 

Author Comment

by:finkeltron
ID: 39792553
Darn, this is not going to work. I need to the command from GFI remote management. It downloads a complied RDP file so all the parameters need to be on that line in the screenshot.GFI
0
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39792614
Sorry, no way then. Unless you can change from "Terminal Services" to "Run an external batch or tool".
0
 

Author Comment

by:finkeltron
ID: 39792633
Embedded feature? I don't follow.
0
 

Author Closing Comment

by:finkeltron
ID: 39792727
No solution found
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MS Project Critical Path 4 71
Problem to refer to cell 8 75
Excel Automation of Autosum 23 85
ost file to pst 10 51
MS Access 2003 or later To MySQL Migration Project Hello All, this is my second article in the category of MS-OFFICE Automation. In internet I am not able to find any comprehensive resource on the Migration of MS Access back-end to MySQL so I fin…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Viewers will learn the different options available in the Backstage view in Excel 2013.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now