Saty Posted January 29, 2018 Share Posted January 29, 2018 (edited) 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? expandcollapse popup#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 January 29, 2018 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Saty Posted January 29, 2018 Author Share Posted January 29, 2018 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? expandcollapse popup#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 More sharing options...
FMS Posted January 29, 2018 Share Posted January 29, 2018 do you get error's? what isn't working? as finishing touch god created the dutch Link to comment Share on other sites More sharing options...
Saty Posted January 29, 2018 Author Share Posted January 29, 2018 Nothing happens. it remains blank. I am not getting any notifications on successful connection! Link to comment Share on other sites More sharing options...
gcriaco Posted April 9, 2020 Share Posted April 9, 2020 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now