-1

I'm trying to launch a remote desktop session to a specified IP on an onClick function on a menuItem in VS.

private void NAMEHEREToolStripMenuItem_Click(object sender, EventArgs e)
    {
        // launch remote desktop to 192.168.0.1
    }

So I click NAMEHERE and it should open remote desktop and automatically connect to the IP I've given it. How can I do this? I've googled different things but cant quite find what I want.

Thanks!

Vaughan Slater
  • 115
  • 1
  • 2
  • 8

2 Answers2

0

On Windows you can launch the remote desktop program with the /v argument, like this:

mstsc.exe /v 192.168.0.1

you can also define a port after the IP if needed: 192.168.0.1:1234 for example.

For all arguments, launch it in command propmt:

mstsc.exe -?
user1365830
  • 171
  • 1
  • 11
0

and to start the process:

// launch remote desktop to 192.168.0.1
var ipAddress = "192.168.0.1";
var pinfo = new System.Diagnostics.ProcessStartInfo("mstsc.exe");
pinfo.Arguments = "/v " + ipAddress;
Process.Start(pinfo);
Phil
  • 84
  • 5