Jump to content

AutoIT Evaluate Conditions


danr29

Recommended Posts

Hello! I have created an AutoIT script to upgrade a file for 2 different versions of an application but I am having an issue evaluating a 3rd condition. The following is the script I have put together:

; Script Function:

; Performs configuration upgrade to either Integrity Agent 5 or Integrity Agent 6

;

$IA6PATH = "c:\Program Files\checkpoint\integrity client\iclient.exe"

$IA5PATH = "c:\Program Files\zone labs\Integrity Client\iclient.exe"

$GO1 = '"C:\Program Files\Zone Labs\Integrity Client\iclient.exe" -config "\\(machinename)\C$\temp\reconfig\ServerIP.xml"'

$GO2 = '"C:\Program Files\checkpoint\Integrity Client\iclient.exe" -config "\\(machinename)\C$\temp\reconfig\ServerIP.xml"'

;

If $IA5PATH = 1

Then

Run($IA5)

Else

Run($IA6)

Endif

;

WinWaitActive("Reconfiguration Confirmation")

Send("{ENTER}")

I need to enter in a 3rd condition that will exit if the script cannot find either of the directories ($IA5 or $IA6). I've tried using Elseif, separate If...Then, Select Case statements and subroutines but none have worked. If someone can just explain the proper way to evaluate multiple conditions in AutoIT I can have this script finally working the right way. Thank you.

-Dan

Link to comment
Share on other sites


Hello! I have created an AutoIT script to upgrade a file for 2 different versions of an application but I am having an issue evaluating a 3rd condition. The following is the script I have put together:

; Script Function:

; Performs configuration upgrade to either Integrity Agent 5 or Integrity Agent 6

;

$IA6PATH = "c:\Program Files\checkpoint\integrity client\iclient.exe"

$IA5PATH = "c:\Program Files\zone labs\Integrity Client\iclient.exe"

$GO1 = '"C:\Program Files\Zone Labs\Integrity Client\iclient.exe" -config "\\(machinename)\C$\temp\reconfig\ServerIP.xml"'

$GO2 = '"C:\Program Files\checkpoint\Integrity Client\iclient.exe" -config "\\(machinename)\C$\temp\reconfig\ServerIP.xml"'

;

If $IA5PATH = 1

Then

Run($IA5)

Else

Run($IA6)

Endif

;

WinWaitActive("Reconfiguration Confirmation")

Send("{ENTER}")

I need to enter in a 3rd condition that will exit if the script cannot find either of the directories ($IA5 or $IA6). I've tried using Elseif, separate If...Then, Select Case statements and subroutines but none have worked. If someone can just explain the proper way to evaluate multiple conditions in AutoIT I can have this script finally working the right way. Thank you.

-Dan

try this. I don't know if both could ever exist together but who knows. I don't know your environment.

$IA6PATH = FileExists(@ProgramFilesDir & '\checkpoint\integrity client\iclient.exe')
$IA5PATH = FileExists(@ProgramFilesDir & '\zone labs\Integrity Client\iclient.exe')

If $IA5PATH = 1 and $IA6PATH = 0 Then
FileChangeDir(@ProgramFilesDir & '\Zone Labs\Integrity Client')
Run('iclient.exe -config ' & '"\\(machinename)\C$\temp\reconfig\ServerIP.xml"')
WinWaitActive('Reconfiguration Confirmation')
Send('{ENTER}')
Elseif $IA5PATH = 0 and $IA6PATH = 1 Then
FileChangeDir(@ProgramFilesDir & '\checkpoint\integrity client')
Run('iclient.exe -config ' & '"\\(machinename)\C$\temp\reconfig\ServerIP.xml"')
WinWaitActive('Reconfiguration Confirmation')
Send('{ENTER}')
Elseif $IA5PATH = 0 and $IA6PATH = 0 Then
Msgbox(0, 'None found', 'Neither was found.')
endif

That should work. I would personally use ControlClick() instead of that Send('{ENTER}'). That's risky if that window is not in focus. I like the FileChangeDir() command in there because I feel it's better to run arguments that way but it's just a matter of preference. You could also have AutoIt check the version of the iclient.exe if you wanted but that may be out of the scope of your needs.

Tell me if that works.

-Redfive

Link to comment
Share on other sites

Glad to hear! I love it when a plan comes together.

As far as the ControlClick() goes, your best bet is to read the AutoIt help file. Basically it "clicks" a button for you instead of you sending enter. For instance:

ControlClick('Reconfiguration Confirmation', '', 'Button1')

Where 'Reconfiguration Confirmation' is the title of the window, '' is any text in the window and 'Button1' is the name of the button you want to click.

You get the info the same way you got the title of that window - with the AutoIt Window Info tool. Hover over the 'OK' button or whatever button ENTER clicks. It should tell you what button name it is.

Link to comment
Share on other sites

Yeah the ControlClick function is a little tricker. I've found some examples online but there all inconsistant w/ each other. But I should be able to figure it out. Thanks a lot.

Link to comment
Share on other sites

if you send me the AutoIt window info text, I can send you the code. In fact, I am almost positive that the code I just posted might just work if there's only one button!

Give it a try. Replace the

Send('{ENTER}')

with

ControlClick('Reconfiguration Confirmation', '', 'Button1')

Link to comment
Share on other sites

OK cool I got it to work. I just replaced the 'button1' statement with 'Yes' (the name of the button to click on) and it worked great. Again thanks for the help.

-Dan

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

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