remote desktop - How to Automatically Start an RDP Connection with mRemoteNG? - Stack Overflow

admin2025-05-01  1

I'm working on an application that integrates with mRemoteNG. The application dynamically modifies the confCons.xml file to add new connections. The goal is to launch mRemoteNG and have it automatically initiate an RDP connection.

using C# method:

static void OpenMRemoteNG(string mremotePath, string connName, string description, string ip, int port, string username)
{
    try
    {
        string connectionId = AddConnectionToXml(connName, description, ip, port, username);
        if (string.IsNullOrEmpty(connectionId))
        {
            return;
        }

        Thread.Sleep(1000);

        var process = new Process
        {
            StartInfo = new ProcessStartInfo
            {
                FileName = mremotePath,
                UseShellExecute = true
            }
        };
        process.Start();

        process.WaitForExit();

        RemoveTempConnectionFromXmlById(connectionId);
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Error launching mRemoteNG: {ex.Message}");
    }
}
  1. With this I can add a connection in confCons.xml using AddConnectionToXml, which returns the connection node ID.

  2. Then mRemoteNG is launched automatically with the updated configuration file.

  3. To finish, when mRemoteNG is closed the temporary connection from confCons.xml is removed.

The issue is that when mRemoteNG launches, it only loads the connection list. It doesn't automatically start the RDP connection. I've looked into the documentation and possible command-line options but haven't found a way to achieve this. Is there a specific command-line parameter or configuration setting in mRemoteNG to automatically start the RDP connection when the applicaction launches?

转载请注明原文地址:http://www.anycun.com/QandA/1746113544a91856.html