Jump to content

Recommended Posts

Posted

Hi,

i am trying to create a easy way for our employees to login to servers using RDP.

This is the first stage later on the username and passwords will be automaticly entered when choosing the server.

I have found this code on the forum and am trying to get in to work however it is not connecting.

Perhaps I am missing something here?

Source: https://www.autoitscript.com/forum/topic/133217-rdp-session-in-autoit-gui/
Post: ByteSniper

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

#RequireAdmin

Opt("GUIOnEventMode", 1)

$hGUI = GUICreate("RDP", 1401, 801, 193, 115)
    GUISetOnEvent($GUI_EVENT_CLOSE, "hGUIClose")
$Connect = GUICtrlCreateButton("Connect", 1272, 16, 115, 33, 0)
    GUICtrlSetOnEvent(-1, "ConnectClick")

GUICtrlCreateLabel("Username:", 1272, 130)
$USER = GUICtrlCreateInput("", 1272, 150, 115, 23)

GUICtrlCreateLabel("Password:", 1272, 180)
$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)

Call("Load_srv")

While 1
    Sleep(100)
WEnd

Func ConnectClick()
$GO = 1
$host   = GUICtrlRead($serveur,1) ;<<<<<<< enter here the host name or ip address
$Name   = GUICtrlRead($USER)
$Pass   = GUICtrlRead($Password)
    If $host = "" Then
        MsgBox(4096, "", "Please choose a server.")
        $GO = 0
    EndIf
    If $Name = "" Then
        MsgBox(4096, "", "Please fill in a username.")
        $GO = 0
    EndIf
    If $Pass = "" Then
        MsgBox(4096, "", "Please fill in a password.")
        $GO = 0
    EndIf

    If $GO = 1 Then
        $oRDP.Server = $host
        $oRDP.UserName = $Name
        $oRDP.Domain = ""
        $oRDP.AdvancedSettings2.ClearTextPassword = $Pass
        $oRDP.ConnectingText = "Connecting to " & $host
        $oRDP.DisconnectedText = "Disconnected from " & $host
        $oRDP.StartConnected = True
        $oRDP.connect()
    EndIf

EndFunc

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

Func hGUIClose()
exit
EndFunc

 

[serveurs]

Server1 = 192.168.2.2

Server2 = Server2

Server3 = Server3

 

Posted

It sounds like a security nightmare and it’s already easy for employees to use already Use rdp. Rdp is a no brainer to use So I don’t even see the point of automating anything

My resources are limited. You must ask the right questions

 

Posted

Automating the credentials, when we replace a workstation or a new employee logs in he needs to input the credentials. From autoit i would be able to send the credentials.

Posted (edited)

new employees should be assigned credentials that work across the network. I still don't get it. Domain users should use their own, and never anyone elses. what is this going to save the user? 2 seconds? anyway, best of luck

 

rdp can create a shortcut already and have it ALWAYS ask for credentials. it should be installed on every new workstation, all the links to servers they need, and they just add their credentials to each when they log in.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

  • Moderators
Posted

@Wingens why are you reinventing the wheel, rather than using Remote Desktop Connection Manager? Then, if you need to add features you can just automate the RDCM.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

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