Programmatically create and run an RDP session (without gui)

I would like to know if there is a way to create and start a remote desktop session on Windows Server programmatically.

I am trying to create an automatic tool to create local users and then start an associated RDP session. I have already created LocalUser and am adding them to Remote Desktop users (using net.exe). But I am amazed at the next step: create and run a custom rdp session. I do not know how to deal with this problem without having a Gui remote desktop client.

I am working on Windows Server 2003 and I am using VS2008 with .NET 3.5.

Sincerely.

+4
source share
3 answers

You can use the ActiveX ActiveX element to connect, you will need to place it on the form, but the form should not be visible. For an example see http://www.codeproject.com/KB/cs/RemoteDesktop_CSharpNET.aspx

+1
source

You can call mstsc.exe and pass parameters on the command line to tell you what to connect to.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ts_cmd_mstsc.mspx?mfr=true

+12
source

First, I found that a server option is required to enable the Terminal Services Authorized Services.

  • On the terminal server, click the Start button, select Programs, Administrative Tools, and then click Connect to Terminal Server Configuration.
  • Double-click the rdp-tcp connection and click Advanced. If you want to change the properties for ICA Clients, double-click the ica-rdp icon instead, and then click Properties.
  • In the AutoLogon section, click to clear the "Password Verification Request" box.
  • Click OK, then OK, and then Exit from the Connection menu.

source: support.microsoft.com/kb/260711

After that, I did something based on this project: codeproject.com/KB/cs/RemoteDesktop_CSharpNET.aspx For what I tested, I think it is impossible to skip the RDP client connection (MsTscLib or mstsc.exe) I have something- that works, but it is definitely a bad style. I use ActiveX Component Events to find out the result of the connection. That is: OnLogonError and OnLoginComplete.

here is my source: http://codepaste.net/uiuuxc

I am waiting for your comments.

0
source

Source: https://habr.com/ru/post/1308794/


All Articles