Link to home
Start Free TrialLog in
Avatar of QUILLET
QUILLET

asked on

Remote App failed to launch using MSTSCLib API

Hi,

I am using MSRDPClient in a c# winform application and can't get to launch a remote app.
The following code is working for opening a desktop control if I comment out rdp.RemoteProgram.RemoteProgramMode = true;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using AxMSTSCLib;

namespace SampleRDC
{
    public partial class Form1 : Form
    {
        // initialized in form1.Designer
        // private AxMSTSCLib.AxMsRdpClient7NotSafeForScripting rdp;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {

                rdp.Server = txtServer.Text;
                rdp.UserName = txtUserName.Text;

                rdp.OnConnected += new EventHandler(rdp_OnConnected);

                rdp.RemoteProgram.RemoteProgramMode = true;
                //rdp.RemoteProgram2.RemoteApplicationName = "Calculator";
                //rdp.RemoteProgram2.RemoteApplicationProgram = @"C:\Windows\system32\calc.exe";
                
                rdp.AdvancedSettings7.ClearTextPassword = txtPassword.Text;
                rdp.Connect();               

            }
            catch (Exception Ex)
            {
                MessageBox.Show("Error Connecting", "Error connecting to remote desktop " + txtServer.Text + " Error:  " + Ex.Message,MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        void rdp_OnConnected(object sender, EventArgs e)
        {

            rdp.RemoteProgram.ServerStartProgram(@"C:\Windows\system32\calc.exe", "", "", false, "", false);
        }
   }
}

Open in new window


Trying to launch a remote app using :

rdp.RemoteProgram.RemoteProgramMode = true;
...
            rdp.RemoteProgram.ServerStartProgram(@"C:\Windows\system32\calc.exe", "", "", false, "", false);

nothing happens and the connected event is never fired.

The client dev environnment is VS 2010 on Windows 7 Pro SP1
The target environnement is WS2008R2,
The TS Server is WS2003

Thanks for helping me
ASKER CERTIFIED SOLUTION
Avatar of QUILLET
QUILLET

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial