Sign in to follow this  
Followers 0
jayshomp

GUI and passwords

10 posts in this topic

Hi all,

First off let me tell you that unfortunately I am completely new to anything scripting ;)

Now here's my situation and question(s)

I need to set up a script to automatically log into 26 different Citrix servers through MS' Terminal Services Client(MSTSC.exe). This is what I have so far(I know it's basic and rough, please don't make fun :) )

Run("MSTSC.EXE")
WinWaitActive("Terminal Services Client")
Send("Server Name 1")
Send("!c")
Send("{Down 2}");FYI, this is for selecting the resolution
Send("{ENTER}")
WinWait("Server Name 1")
Sleep(2000)
Send("!u")
Send("username")
Send("!p")
Send("password")
Send("!l")
Send("u");FYI, this is the first letter of the domain name
Send("{TAB}")
Send("{ENTER}")
Sleep(2000)

Run("MSTSC.EXE")
WinWaitActive("Terminal Services Client")
Send("Server Name 2")
Send("!c")
Send("{Down 2}")
Send("{ENTER}")
WinWait("Server Name 2")
Sleep(2000)
Send("!u")
Send("username")
Send("!p")
Send("password")
Send("!l")
Send("u")
Send("{TAB}")
Send("{ENTER}")
Sleep(2000)

etc etc......

That works fine, but what I want to avoid is including the username/password in the script itself. Is it possible to create a GUI or similar where I can just input the username/password once for all servers? If so I'd appreciate it if someone could point me in the right direction, maybe examples or what specifically I should look for in the help file. Thanks in advance!

Share this post


Link to post
Share on other sites



The helpfile does wonders.

Read it.

InputBox()

Share this post


Link to post
Share on other sites

The helpfile does wonders.

Read it.

InputBox()

Yes thank you.

I see that's probably something I would need to use but HOW to use it is another story. I just want to have to enter that password once, which will automatically enter that into each instance of the server log in screens. Would that accomplish that? If so, I will research that more thoroughly.

Thanks again

PS- Just as an FYI, I don't ask questions without first looking through the help file, these forums, and Google. Please remember that I'm completely new at this, and even though something might be there in the help file, I'm not able to always comprehend it, especially while I'm still trying to get the basics down. Wouldn't got as far as I have without reading the help file. Please keep that in mind before answering in a condescending tone.

Share this post


Link to post
Share on other sites

Store the value you input in a variable:

$MyVariable = InputBox("Input", "Enter something")
MsgBox(0, "You entered", $MyVariable)

Share this post


Link to post
Share on other sites

I guess I'm reading it different than others.

Yes you can use an InputBox for them to enter the password.

Yes you can store the value of the InputBox in a variable.

What I'm understanding is you only want them to have to do it once.

So what I would do, is have a value in the:

Registry (Using RegRead/RegWrite) or an Ini File (Using IniRead/IniWrite) or a regular Text File (Using FileRead/FileWrite)

To read the registry/ini/file to see if the value exists, and if it doesn't then have the InputBox and write the value from the input box into the file for the next start up...

Psuedo (Place at the top of the script):

Global $sPassWord = _CheckPass("MyIniFile.ini", "Password", "UserPass")

MsgBox(64, "Example", "Pass Found = " & $sPassWord)

Func _CheckPass($hFile, $sSection, $sKey)
    Local $sPass = IniRead($hFile, $sSection, $sKey, "")
    If $sPass = "" Then
        While $sPass = ""
            $sPass = InputBox("Create a password", "No password was found, please create below.", "", 120, 80, Default)
        WEnd
        IniWrite($hFile, $sSection, $sKey, $sPass)
    EndIf
    Return $sPass
EndFunc

Hmm, looks like InputBox is broke on Height param, makes me put the "Left" param and doesn't resize it... Anyway, this should give you an idea.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thank you FreeFry and SmOke_N.

SmOke_N,

You understood correctly about only having to enter the password once, but, unless I can talk the client out of it, they don't want the password stored anywhere. So I guess I really can't have it check for the correct password. I just want to be prompted for a password once without the script knowing it's correct or not, and have it automatically entered for the server log ins. Of course the major downside being that if a wrong password is entered, all those 26 log in attempts are going to fail.

And I think because I'm using the word "password" I'm confusing people. Let me put it a different way. I want an input box to pop up when the script(see 1st post) is run, and whatever string is put in that box, I want it to be in place of the word "password" in the following statement:

Send("username")
Send("!p")
Send("password")

Sorry, being new to this means I don't have the lingo down so it's hard to explain exactly what I want. Thank you for bearing with me :)

Edited by jayshomp

Share this post


Link to post
Share on other sites

Good Luck. :)

Share this post


Link to post
Share on other sites

You know, I had a similar issue - I think.

I had a lot of apps to log into, but didn't want to have to enter there passwords each time. I equally didn't want to leave the passwords exposed in a clear text file. My solution: encrypt the passwords in an ini file, using a single master password as a key:

The following functions:

1. encryptPassword: Read the sections of an ini file and encrypt the key named "ClearPassword" and save as "EncryptPassword" then remove the ClearPassword, using $masterPassword as the encrypt key

2. retreivePassword: Read the ini file and return the clear password for a given section using $masterPassword to decrypt

3. VerifyPassword: Uses $masterPassword to decrypt a control password and make sure that the string matches the expected value - no point carrying on it all the passwords are wrong.

I am sure that this wouldn't pass any hardcore security checks, but it suited my purposes.

#Include <String.au3>

func VerifyPassword($sMasterPassword)
    $sControlPassword = iniRead ($sPasswordFile,"Control","ControlPassword","none")
    $sControlTest = _StringEncrypt(0, $sControlPassword, $sMasterPassword)

    if $sControlTest <> "control" then
        msgbox (0,"WARNING","entered password does not match the master password - re-run to try again" & Chr(10) & $sControlPassword &":"& $sControlTest )
        return 1
    Else
        return 0
    endif

endfunc

func encryptPasswords($sMasterPassword)
    $aServices = IniReadSectionNames ($sPasswordFile)
    for $sService in $aServices
        $sClearPassword = iniRead ($sPasswordFile,$sService,"ClearPassword","none")
        if $sClearPassword <> "none" then
            $sEncServPassword = _StringEncrypt(1, $sClearPassword, $sMasterPassword)
            IniWrite($sPasswordFile,$sService,"EncryptPassword",$sEncServPassword)
            IniDelete($sPasswordFile,$sService,"ClearPassword")
        endif
    Next
endfunc

func RetreivePassword($sSection,$sMasterPassword)
    $sEncPassword = iniRead ($sPasswordFile,$sSection,"EncryptPassword","none")
    $sClearPassword=_StringEncrypt(0, $sEncPassword, $sMasterPassword)
    if @error = 1 Then
        $sClearPassword="ERROR"
    endif
    return $sClearPassword
endfunc

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
Sign in to follow this  
Followers 0