Solved

Remote Desktop Client CLI RDP Gateway

Posted on 2014-01-18
11
1,177 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access Convert Columns into Rows 5 73
cron.exe SCOM alert 3 51
Excel To Access Database Transfer 14 71
Computers reporting Windows patches applied 14 104
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
This collection of functions covers all the normal rounding methods of just about any numeric value.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.

803 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