Solved

Remote Desktop Client CLI RDP Gateway

Posted on 2014-01-18
11
1,317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
11 Comments
 
LVL 70

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 70

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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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
 
LVL 70

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 70

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
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 …
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 …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

751 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