How can I start an application on a remote connection created through MSTSCLib and .Net?

43 Views Asked by At

I have created a WinForm .Net app that uses MSTSCLib to open a Remote Desktop Connection to a server. The goal is to then open/launch an application on this session.

So the code I am using is:

AxMsRdpClient8NotSafeForScripting rdpConnection2 = new AxMsRdpClient8NotSafeForScripting();
rdpConnection2.Server = server;
//rdpConnection.Server = ipAddress;
rdpConnection2.UserName = username;
rdpConnection2.Domain = domain;
rdpConnection2.RemoteProgram.RemoteProgramMode = true;

rdpConnection2.MsRdpClientShell.PublicMode = true;

rdpConnection2.AdvancedSettings8.AuthenticationLevel = 0
rdpConnection2.AdvancedSettings8.EnableCredSspSupport = true;
rdpConnection2.RemoteProgram2.RemoteProgramMode = true;
rdpConnection2.AdvancedSettings8.DisplayConnectionBar = true;
            
rdpConnection2.AdvancedSettings8.ClearTextPassword = password;
            
rdpConnection2.SecuredSettings.StartProgram = @"C:\Windows\System32\calc.exe";
//rdpConnection2.SecuredSettings.StartProgram = remoteApp;

//// Start connection
rdpConnection2.Connect();

Running this code, the application displays the Connecting screen and then it freezes and sometimes spits out this error: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

If I comment out:

rdpConnection2.RemoteProgram.RemoteProgramMode = true;

The application connects to the Remote Desktop but doesn't launch the additional app (calculator).

If I try using the rdp_OnConnected event instead, still nothing happens.

Any guidance on how to get this application to start would be greatly appreciated.

0

There are 0 best solutions below