Solved

Remote Desktop Client CLI RDP Gateway

Posted on 2014-01-18
11
1,409 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
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 …
Suggested Courses

617 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