Search code examples
c#winformsprocesswinforms-interopremoteapp

Opening Remote App inside the Panel


I am trying to load the Remote app in my windows form panel but i am not able to do it. Currently the remote app opens as a normal remote app. Is there any way I can open this remote app within the windows form.

Here is the code which get triggers when user pressed a button.

private void openProgram()
        {

            Process rdcProcess = new Process();
            rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\cmdkey.exe");
            rdcProcess.StartInfo.Arguments = "/generic:TERMSRV/xyz.domain.com /user:" + "username" + " /pass:" + "password";
            rdcProcess.Start();

            rdcProcess.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\mstsc.exe");
            rdcProcess.StartInfo.Arguments = @"\\10.10.1.5\myshare\PSTools\Mozilla\RemoteFirefox.rdp";
            rdcProcess.Start();          
        }

Solution

  • If I understood you question, you want to embed Remote desktop in your form, in this case you can use Microsoft RDP Client Control ActiveX, here is a simple example:

    1- Reference Microsoft RDP Client Control:

    On Visual Studio Open Toolbox --> Right-Click --> Click Choose Items... --> Select COM Components Tab --> Check Microsoft RDP Client Control (Redistributable)

    enter image description here

    2-Put RDP Control On Form:

    From Toolbox --> Select Microsoft RDP Client Control

    OK, We are ready, here is the code for establishing a remote desktop session:

        private void connectButton_Click(object sender, EventArgs e)
        {
            axMsRdpClient81.Server = "192.168.1.100"; //IP address of remote machine
            axMsRdpClient81.Connect();
        }
    

    Here is a screenshot of the example:

    enter image description here