Jump to content
Saty

RDP Automation

Recommended Posts

Saty

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

Share this post


Link to post
Share on other sites
Saty
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

 

 

Share this post


Link to post
Share on other sites
FMS

do you get error's?

what isn't working?


as finishing touch god created the dutch

Share this post


Link to post
Share on other sites
Saty

Nothing happens. it remains blank. I am not getting any notifications on successful connection!

Share this post


Link to post
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

×