Generating RDP file on the fly

☆樱花仙子☆ 提交于 2019-12-04 05:51:09
Naraen

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.

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...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!