以编程方式启动RemoteApp而无需系统调用" mstsc"

时间:2014-04-04 10:52:35

标签: c# windows-server-2008-r2 rdp remoteapp

我已成功启动RemoteApp的RDP文件。

remoteapplicationmode:i:1
remoteapplicationprogram:s:||application
remoteapplicationname:s:application.exe
remoteapplicationcmdline:s:
authentication level:i:2
gatewayusagemethod:i:2
gatewayprofileusagemethod:i:1
gatewaycredentialssource:i:0
full address:s:aaa.bbb.ccc.com

我尝试将其设置复制到我的C#对象中:

AxMsRdpClient7NotSafeForScripting rc = new AxMsRdpClient7NotSafeForScripting();
rc.OnConnected += (_1, _2) => { rc.RemoteProgram2.ServerStartProgram("application.exe", "", "%HOMEDRIVE%" + "%HOMEPATH%", true, "", true); };
rc.RemoteProgram2.RemoteProgramMode = true;
rc.RemoteProgram2.RemoteApplicationProgram = "||application";
rc.RemoteProgram2.RemoteApplicationName = "application.exe";
rc.TransportSettings.GatewayUsageMethod = 1;
rc.TransportSettings.GatewayProfileUsageMethod = 1;
rc.TransportSettings.GatewayCredsSource = 0; 
rc.Server = "aaa.bbb.ccc.com";
rc.UserName = "DOMAIN\\user";
rc.AdvancedSettings7.PublicMode = false;
rc.AdvancedSettings7.ClearTextPassword = "pass";
rc.AdvancedSettings7.AuthenticationLevel = 2;
rc.DesktopWidth = SystemInformation.VirtualScreen.Width;
rc.DesktopHeight = SystemInformation.VirtualScreen.Height;
rc.AdvancedSettings7.SmartSizing = true;
rc.Connect();

我一直在搜索,但我无法找到任何以编程方式启动RemoteApp的示例。

我是红色this page,但它不是很有帮助。客户端(COM控件)连接成功,但它只显示蓝屏,并且没有启动RemoteApp。

此外,我不确定启动rc.RemoteProgram2.ServerStartProgram的正确方法,因为它将路径作为参数,而在我的RDP文件中没有路径存在!

任何人都可以帮助我吗?我使用正确的对象来做我想做的事情吗?

服务器运行Windows Server 2008R2

1 个答案:

答案 0 :(得分:0)

如果你想要做的只是实际启动RemoteApp,你已经有了一个rdp文件,那么就把它作为一个过程启动:

System.Diagnostics.Process.Start(@"C:\Path_To_Rdp_File.rdp");