Answered by:
Connect to Remote desktop(RDP) with servername and port number using C#

Question
-
Iam able to connect to Remote desktop(RDP) with IP address, Username and password using AxMsRdpClient5NotSafeForScripting class.
For example:
public void RDPConnect()
{private AxMSTSCLib.AxMsRdpClient5NotSafeForScripting connectorRDP;
connectorRDP.Server = "225.123.234.112"
connectorRDP.UserName = "UserName";
IMsTscNonScriptable secured = (IMsTscNonScriptable)connectorRDP.GetOcx();
secured.ClearTextPassword = "Password";
connectorRDP.Connect();
}
But i want to connect to a specific port of RDP like "225.123.234.112:1103"
In above code, connectorRDP.Server is not accepting ':' and there is no option to set port number.
Please give suggestions/ alternatives to do this in C#.
Thanks in advance
Monday, October 8, 2012 6:23 PM
Answers
-
I'm not exactly sure why you want to do this. Are yo tryuing to connect into an existing Terminal Session. I did a research on the problem but did find an answer. Here is what I found
The dll you are using is AxInterop.MSTSCLib.dll which the webpage below says can be generated from mstscax.dll
http://coolthingoftheday.blogspot.com/2005/10/microsoft-remote-desktop-control-in.htmlmstscax.dll is the Microsoft Remote Desktop Service and the documentation can be found below.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb892075(v=vs.85).aspx
This code project may help you solve you problem. it gets a list of remote machine connections and then connects to an erxisitng connection rather than connect through a specific port number.
http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=19836
jdweng
- Proposed as answer by Jason Dot WangModerator Friday, October 12, 2012 4:46 AM
- Marked as answer by Jason Dot WangModerator Tuesday, October 16, 2012 9:10 AM
Tuesday, October 9, 2012 5:27 AM
All replies
-
I'm not exactly sure why you want to do this. Are yo tryuing to connect into an existing Terminal Session. I did a research on the problem but did find an answer. Here is what I found
The dll you are using is AxInterop.MSTSCLib.dll which the webpage below says can be generated from mstscax.dll
http://coolthingoftheday.blogspot.com/2005/10/microsoft-remote-desktop-control-in.htmlmstscax.dll is the Microsoft Remote Desktop Service and the documentation can be found below.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb892075(v=vs.85).aspx
This code project may help you solve you problem. it gets a list of remote machine connections and then connects to an erxisitng connection rather than connect through a specific port number.
http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=19836
jdweng
- Proposed as answer by Jason Dot WangModerator Friday, October 12, 2012 4:46 AM
- Marked as answer by Jason Dot WangModerator Tuesday, October 16, 2012 9:10 AM
Tuesday, October 9, 2012 5:27 AM -
rdp.AdvancedSettings2.RDPPort = rdpport;
I hope this will help you.
Saturday, December 15, 2012 1:54 PM -
rdp.AdvancedSettings2.RDPPort = rdpport;
I hope this will help you.
Saturday, December 15, 2012 1:54 PM -
rdp.AdvancedSettings2.RDPPort = rdpport;
I hope this will help you.
Saturday, December 15, 2012 1:55 PM