Solved

Remote Desktop Client CLI RDP Gateway

Posted on 2014-01-18
11
1,263 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 69

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 69

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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 69

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 69

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

680 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