Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating RDP file on the fly

I want to create a web application similar to TS Web Access, where I can create rdp files on the fly for Remote Apps configured on the server. Any idea??

like image 582
Gaurav Arya Avatar asked Nov 19 '09 09:11

Gaurav Arya


People also ask

How do I save an RDP file?

Select the computer you want to save its connection settings. Next, click/tap on Show Options in the Remote Desktop Connection client. Click/tap on the Save As button in the Connection settings section. Browse to a location your local drive where you want to save the RDP file.

What is a .RDP file?

Contains the necessary information for a connection to a terminal server, including the configuration of the options when the file was saved; used by Microsoft's Remote Desktop Services and related applications.


2 Answers

We had to do this exact thing.

private void InvokeRDPSign(String fileName, String certificateThumbPrint)
{
    Process signingProcess = new Process();
    signingProcess.StartInfo.FileName = @"rdpsign.exe";

    String arguments = String.Format("/sha1 {0} {1}", certificateThumbPrint, fileName);
    signingProcess.StartInfo.Arguments = arguments;
    signingProcess.StartInfo.UseShellExecute = false;
    signingProcess.StartInfo.RedirectStandardOutput = true;
    signingProcess.StartInfo.WorkingDirectory = Environment.SystemDirectory;
    signingProcess.Start();

    String signingOutput = signingProcess.StandardOutput.ReadToEnd();
    signingProcess.WaitForExit();
    int exitCode = signingProcess.ExitCode;
    //TODO:  should we throw an error if the exitcode is not 0
}

Be aware that that the RDPSign.exe is different on each version of windows. You will find that an older version of the utility will ignore newer settings from the signature.

like image 65
Naraen Avatar answered Nov 15 '22 09:11

Naraen


well Having looked at a 'rdp' file this is the contents:

screen mode id:i:2
desktopwidth:i:1280
desktopheight:i:768
session bpp:i:32
winposstr:s:2,3,1430,104,2230,704
compression:i:1
keyboardhook:i:2
displayconnectionbar:i:1
disable wallpaper:i:1
disable full window drag:i:1
allow desktop composition:i:0
allow font smoothing:i:0
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s: [YOUR IP]
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:1
drivestoredirect:s:

Just create that as a string, seems straightforward.

ps I have no idea what the 'winposstr' parameter is...

like image 20
Darknight Avatar answered Nov 15 '22 09:11

Darknight