Jump to content

RDP Automation


Recommended Posts

I am looking for a Script with which i can automate the RDP to a Windows10 PC. 
The examples based on RDP Embedded Sessions ("MsTscAx.MsTscAx.x / MsRDP.MsRDP.x" - http://msdn.microsoft.com/en-us/library/aa381344(v=VS.85).aspx)
from several posts are working just in case the target machine is running IIS.
I'm wondering if it's possible to use these ActiveX or other features for PCs without IIS too.

Any help?

Thanks
Peppe

Link to comment
Share on other sites

This "quick and dirty" workaround works:

local $iPid = run("mstsc.exe /v:IP /public", "", @SW_HIDE)
WinWaitActive("Sicurezza di Windows", "", 3)
Sleep(1000)
Send("User")
Sleep(500)
send("{TAB}")
Sleep(500)
send("Password")
Sleep(500)
send("{ENTER}")
Exit

If somebody knows how to connect to Win10 PCs via ActiveX please let me know. Otherwise, maybe this code could be useful to someone.

 

Regards

Peppe 

Link to comment
Share on other sites

Yes, of course. You have to substitute IP, User and Password with your data.

Moreover, "Sicurezza di Windows" is the RDP Window Title (italian Windows O.S. version):

image.png.33ca4cdc6d52d9f92366febdad29f905.png

You have to sustitute "Sicurezza di Windows" with the correct title of the window.

 As I already said, it's just a workaround, but unfortunately I'm not able to use the RDP ActiveX objects to connect to PCs (just IIS servers)

Link to comment
Share on other sites

This one works for me for RDP connection, but you have to have your credentials stored in cmdkey for the specified target machine:  TERMSRV/TargetName

 

ShellExecute(@SystemDir & "\mstsc.exe", "/v:" & $sServer & " /w:1024 /h:768")            ;Launch the RDP session
 

Link to comment
Share on other sites

Found the solution (described here: stackoverflow)

I need to add the following step to ptrex old topic:

$oRDP.AdvancedSettings8.EnableCredSspSupport = true

Script example:

#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

$host = "IP Address" ;<<<<<<< enter here the host name or ip address
;Remote Desktop ActiveX Control Interfaces -> http://msdn.microsoft.com/en-us/library/aa383022(v=VS.85).aspx
$hGUI = GUICreate("RDP Embedded Sessions", 952, 675, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$oRDP = ObjCreate("MsTscAx.MsTscAx") ;http://msdn.microsoft.com/en-us/library/aa381344(v=VS.85).aspx
$oRDP_Ctrl = GUICtrlCreateObj($oRDP, 64, 44, 800, 600)
GUICtrlSetResizing(-1, $GUI_DOCKALL)
GUICtrlSetStyle($oRDP_Ctrl , $WS_VISIBLE)
$oRDP.DesktopWidth = 1366
$oRDP.DesktopHeight = 768
$oRDP.Fullscreen = 768
$oRDP.ColorDepth = 32
$oRDP.AdvancedSettings2.RedirectDrives = True ; Sollen die Laufwerke mitgenommen werden
$oRDP.AdvancedSettings2.RedirectPrinters = False ; Sollen die Drucker mitgenommen werden
$oRDP.AdvancedSettings2.RedirectPorts = False ; Ports wie LPT1 etc
$oRDP.AdvancedSettings2.RedirectSmartCards = False ; SmartCards für Authentifizierung
$oRDP.AdvancedSettings2.EnableAutoReconnect = False
$oRDP.AdvancedSettings2.allowBackgroundInput = False
$oRDP.AdvancedSettings2.ConnectionBarShowRestoreButton = False
$oRDP.AdvancedSettings3.SmartSizing = True
$oRDP.AdvancedSettings5.AudioRedirectionMode = 0
$oRDP.AdvancedSettings2.ClearTextPassword = "Password" ; <<<<<<< enter here the user password
$oRDP.AdvancedSettings8.EnableCredSspSupport = true
$oRDP.Server = $host
$oRDP.UserName = "Username" ;<<<<<<< enter here the user name
$oRDP.Domain = "domain" ;<<<<<<< enter here the domain name
$oRDP.ConnectingText = "Connecting to " & $host
$oRDP.DisconnectedText = "Disconnected from " & $host
$oRDP.StartConnected = True
$oRDP.Connect()

GUISetState(@SW_SHOW, $hGUI)
;~ ConsoleWrite($oRDP.GetErrorDescription() & @CRLF)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $oRDP.Disconnect()
            Exit
    EndSwitch
WEnd


Hope this post is useful to someone else.

 

regards

Peppe

Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...