Jump to content

RDP Automation


Saty
 Share

Recommended Posts

I am looking for a Script with which i can automate the RDP to a server. The example from previous posts are not working. Any help?

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

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=

    $hGUI = GUICreate("Form1", 1401, 801, 193, 115)
    GUISetOnEvent($GUI_EVENT_CLOSE, "hGUIClose")

    $Connect = GUICtrlCreateButton("Connect", 1272, 16, 115, 33, 0)
    GUICtrlSetOnEvent(-1, "ConnectClick")

    $Password = GUICtrlCreateInput("", 1272, 200, 115, 23, $ES_PASSWORD)
    GUICtrlSetOnEvent(-1, "ConnectClick")

    $oRDP = ObjCreate("MsTscAx.MsTscAx.2") ;http://msdn.microsoft.com/en-us/library/aa381344(v=VS.85).aspx
    $oRDP_Ctrl = GUICtrlCreateObj($oRDP, 4, 4, 1232, 792)
    GUICtrlSetResizing(-1, $GUI_DOCKALL)
    GUICtrlSetStyle($oRDP_Ctrl, $WS_VISIBLE)
    GUICtrlSetStyle($oRDP_Ctrl, $WS_EX_STATICEDGE)

    $oRDP.DesktopWidth = 1240
    $oRDP.DesktopHeight = 800
    $oRDP.Fullscreen = False
    $oRDP.ColorDepth = 16
    $oRDP.AdvancedSettings3.SmartSizing = True

    $serveur = GUICtrlCreateCombo("", 1272, 50, 120, 23)
    GUICtrlSetData(-1, "", "")
    GUICtrlSetFont(-1, 9, 800, 0, "Courier new")
    GUICtrlSetOnEvent(-1, "ConnectClick")

    GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Call("Load_srv")

While 1

    Sleep(100)

WEnd

Func ConnectClick()

    $host = GUICtrlRead($serveur, 1) ;<<<<<<< enter here the host name or ip address

    If $host <> "" Then
        $oRDP.Server = $host
        $oRDP.UserName = "" ;<<<<<<< enter here the user name
        $oRDP.Domain = ""
        $oRDP.AdvancedSettings2.ClearTextPassword = GUICtrlRead($Password)
        $oRDP.ConnectingText = "Connecting to " & $host
        $oRDP.DisconnectedText = "Disconnected from " & $host
        $oRDP.StartConnected = True
        $oRDP.connect()
    EndIf

EndFunc   ;==>ConnectClick

Func Load_srv()

    $var = IniReadSection(@ScriptDir & "\RDP_QC.ini", "Serveurs")
    For $i = 1 To $var[0][0]
;~    MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
        GUICtrlSetData($serveur, $var[$i][1])
    Next

EndFunc   ;==>Load_srv

Func hGUIClose()

    Exit

EndFunc   ;==>hGUIClose

 

Edited by Melba23
Added code tags
Link to comment
Share on other sites

24 minutes ago, Saty said:

I am looking for a Script with which i can automate the RDP to a server. The example from previous posts are not working. Any help?

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

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=

    $hGUI = GUICreate("Form1", 1401, 801, 193, 115)
    GUISetOnEvent($GUI_EVENT_CLOSE, "hGUIClose")

    $Connect = GUICtrlCreateButton("Connect", 1272, 16, 115, 33, 0)
    GUICtrlSetOnEvent(-1, "ConnectClick")

    $Password = GUICtrlCreateInput("", 1272, 200, 115, 23, $ES_PASSWORD)
    GUICtrlSetOnEvent(-1, "ConnectClick")

    $oRDP = ObjCreate("MsTscAx.MsTscAx.2") ;http://msdn.microsoft.com/en-us/library/aa381344(v=VS.85).aspx
    $oRDP_Ctrl = GUICtrlCreateObj($oRDP, 4, 4, 1232, 792)
    GUICtrlSetResizing(-1, $GUI_DOCKALL)
    GUICtrlSetStyle($oRDP_Ctrl, $WS_VISIBLE)
    GUICtrlSetStyle($oRDP_Ctrl, $WS_EX_STATICEDGE)

    $oRDP.DesktopWidth = 1240
    $oRDP.DesktopHeight = 800
    $oRDP.Fullscreen = False
    $oRDP.ColorDepth = 16
    $oRDP.AdvancedSettings3.SmartSizing = True

    $serveur = GUICtrlCreateCombo("", 1272, 50, 120, 23)
    GUICtrlSetData(-1, "", "")
    GUICtrlSetFont(-1, 9, 800, 0, "Courier new")
    GUICtrlSetOnEvent(-1, "ConnectClick")

    GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Call("Load_srv")

While 1

    Sleep(100)

WEnd

Func ConnectClick()

    $host = GUICtrlRead($serveur, 1) ;<<<<<<< enter here the host name or ip address

    If $host <> "" Then
        $oRDP.Server = $host
        $oRDP.UserName = "" ;<<<<<<< enter here the user name
        $oRDP.Domain = ""
        $oRDP.AdvancedSettings2.ClearTextPassword = GUICtrlRead($Password)
        $oRDP.ConnectingText = "Connecting to " & $host
        $oRDP.DisconnectedText = "Disconnected from " & $host
        $oRDP.StartConnected = True
        $oRDP.connect()
    EndIf

EndFunc   ;==>ConnectClick

Func Load_srv()

    $var = IniReadSection(@ScriptDir & "\RDP_QC.ini", "Serveurs")
    For $i = 1 To $var[0][0]
;~    MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
        GUICtrlSetData($serveur, $var[$i][1])
    Next

EndFunc   ;==>Load_srv

Func hGUIClose()

    Exit

EndFunc   ;==>hGUIClose

 

 

Link to comment
Share on other sites

  • 2 years later...

The previous example works fine for me if I connect to a IIS server. It doesn't work if I connect to a PC/Server without IIS installed.

If it's a normal feature of the RDP control, is there any way to connect via RDP to PCs/Servers without IIS?

 

Thanks

Peppe

Link to comment
Share on other sites

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...