Guest User

Untitled

a guest
Oct 16th, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. System.Windows.Forms.SendKeys.Send("^+{ENTER}");
  2.  
  3. https://msdn.microsoft.com/en-us/library/aa382952(VS.85).aspx
  4.  
  5. https://social.msdn.microsoft.com/Forums/vstudio/en-US/76fff61c-a224-40bc-a108-2d3f2f616cd7/microsoft-terminal-services-library-programmatically-execute-a-batch-file-program-on-a-remote?forum=csharpgeneral
  6.  
  7. https://social.technet.microsoft.com/Forums/windowsserver/en-US/2a6c79cc-3890-4899-850c-a938320a4b6e/remoteapp-and-mstsclib?forum=winserverTS
  8.  
  9. https://social.technet.microsoft.com/Forums/windowsserver/en-US/1b3f1f70-9eea-45d8-a6c4-5c5a71e6fa1a/launch-ts-remote-app-from-terminal-services-api?forum=winserverTS
  10.  
  11. ...
  12. this.rdp = new AxMSTSCLib.AxMsRdpClient9NotSafeForScripting();
  13. ...
  14. this.rdp.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("rdp.OcxState")));
  15. ...
  16. private AxMSTSCLib.AxMsRdpClient9NotSafeForScripting rdp;
  17. ...
  18. ...
  19. rdp.Name = "RDP";
  20. rdp.Enabled = true;
  21. rdp.AdvancedSettings.allowBackgroundInput = 1;
  22. rdp.AdvancedSettings2.DisplayConnectionBar = true;
  23. rdp.AdvancedSettings2.SmartSizing = true;
  24. rdp.AdvancedSettings2.RDPPort = 3389;
  25. rdp.TransportSettings.GatewayUsageMethod = 2;
  26. rdp.TransportSettings.GatewayCredsSource = 0;
  27. rdp.TransportSettings.GatewayProfileUsageMethod = 1;
  28. rdp.TransportSettings.GatewayHostname = gateway;
  29. rdp.TransportSettings2.GatewayUsername = username;
  30. rdp.TransportSettings2.GatewayPassword = password;
  31. rdp.DesktopHeight = 768;
  32. rdp.DesktopWidth = 1366;
  33. rdp.Server = server;
  34. rdp.UserName = username;
  35. MSTSCLib.IMsTscNonScriptable secured = (MSTSCLib.IMsTscNonScriptable)rdp.GetOcx();
  36. secured.ClearTextPassword = password;
  37. rdp.ConnectingText = "Connecting...";
  38. rdp.DisconnectedText = "Disconnected";
  39. var ocx = (MSTSCLib.IMsRdpClientNonScriptable5)rdp.GetOcx();
  40.  
  41. ocx.EnableCredSspSupport = true;
  42. ocx.AllowCredentialSaving = false;
  43. ocx.PromptForCredentials = false;
  44. ocx.PromptForCredsOnClient = false;
  45. ocx.WarnAboutSendingCredentials = false;
  46. ocx.AllowPromptingForCredentials = false;
  47. ocx.MarkRdpSettingsSecure = true;
  48.  
  49. //rdp.AdvancedSettings7.DisableRdpdr = 0;
  50. //rdp.CreateVirtualChannels("CH001,CH002");
  51.  
  52. var settings = (MSTSCLib.IMsRdpClientAdvancedSettings8)rdp.AdvancedSettings;
  53. settings.allowBackgroundInput = 1;
  54. settings.ClientProtocolSpec = MSTSCLib.ClientSpec.FullMode;
  55. settings.ConnectToServerConsole = true;
  56. settings.EnableCredSspSupport = true;
  57. settings.EncryptionEnabled = 1;
  58.  
  59. rdp.Connect();
  60. ...
Add Comment
Please, Sign In to add comment