Jump to content

case select


Recommended Posts

I have 2 server where the autoit scripts are located. ("\\server1\software\INSTALLEREN-autoit\") and ("\\10.0.0.1\software\INSTALLEREN-autoit\

How do I make this work. I Tried everything.

here is my latest trial and error.

SELECT
CASE FileExists ("\\server1\software\INSTALLEREN-autoit\")
     $ShellCMD = ("\\server1\software\INSTALLEREN-autoit\")
CASE FileExists ("\\10.0.0.1\software\INSTALLEREN-autoit\")
     $ShellCMD = ("\\10.0.0.1\software\INSTALLEREN-autoit\")
ENDSELECT

$exe = "7-Zip 4.57 Setup"  
$titel = "7-Zip 4.57 Setup"
$window = "7-Zip"


run ($ShellCMD & "7z457.exe")

if not WinActive($titel) then WinActivate($titel, "")

WinWaitActive($titel, "Choose Install Location")
ControlClick($titel, "", "Button2")

WinWaitActive($titel, "Completing the 7-Zip 4.57 Setup Wizard")
ControlClick($titel, "", "Button2")
Exit
Link to comment
Share on other sites

Something like this might work. I also would add further timeout timers for the two windows "Choose Install Location" and "Completing the 7-Zip 4.57 Setup Wizard".

CODE

Global $ShellCMD[2]

Global $Executeable = "7z457.exe"

Global $bExecuteableFound = False

$ShellCMD[0] = "\\server1\software\INSTALLEREN-autoit\"

$ShellCMD[1] = "\\10.0.0.1\software\INSTALLEREN-autoit\"

For $i = 0 To UBound($ShellCMD) - 1

If FileExists($ShellCMD[$i] & $Executeable) Then

$Executeable = $ShellCMD[$i] & $Executeable

$bExecuteableFound = True

EndIf

Next

If $bExecuteableFound = True Then

$exe = "7-Zip 4.57 Setup"

$titel = "7-Zip 4.57 Setup"

$window = "7-Zip"

Run($Executeable)

$iTimeout = TimerInit()

While Not WinExists($titel, "")

Sleep(10)

If TimerDiff($iTimeout) > 3000 Then

MsgBox(0, "Title not found", "Title not found, wait start timed-out.")

Exit

EndIf

WEnd

WinActivate($titel, "")

WinWaitActive($titel, "Choose Install Location")

ControlClick($titel, "", "Button2")

WinWaitActive($titel, "Completing the 7-Zip 4.57 Setup Wizard")

ControlClick($titel, "", "Button2")

Else

MsgBox(0, "Exe not found", "Exe not found")

EndIf

Exit

Link to comment
Share on other sites

Thank you.. seems to be working.

Just have to understand the how and why part.

But now I have something to work on.

Tnx again.

Something like this might work. I also would add further timeout timers for the two windows "Choose Install Location" and "Completing the 7-Zip 4.57 Setup Wizard".

CODE

Global $ShellCMD[2]

Global $Executeable = "7z457.exe"

Global $bExecuteableFound = False

$ShellCMD[0] = "\\server1\software\INSTALLEREN-autoit\"

$ShellCMD[1] = "\\10.0.0.1\software\INSTALLEREN-autoit\"

For $i = 0 To UBound($ShellCMD) - 1

If FileExists($ShellCMD[$i] & $Executeable) Then

$Executeable = $ShellCMD[$i] & $Executeable

$bExecuteableFound = True

EndIf

Next

If $bExecuteableFound = True Then

$exe = "7-Zip 4.57 Setup"

$titel = "7-Zip 4.57 Setup"

$window = "7-Zip"

Run($Executeable)

$iTimeout = TimerInit()

While Not WinExists($titel, "")

Sleep(10)

If TimerDiff($iTimeout) > 3000 Then

MsgBox(0, "Title not found", "Title not found, wait start timed-out.")

Exit

EndIf

WEnd

WinActivate($titel, "")

WinWaitActive($titel, "Choose Install Location")

ControlClick($titel, "", "Button2")

WinWaitActive($titel, "Completing the 7-Zip 4.57 Setup Wizard")

ControlClick($titel, "", "Button2")

Else

MsgBox(0, "Exe not found", "Exe not found")

EndIf

Exit

Link to comment
Share on other sites

It loops through the possible locations, and if it has found found then it exits the loop...

This will select the last valid location found (as in the example above):

For $i = 0 To UBound($ShellCMD) - 1
    If FileExists($ShellCMD[$i] & $Executeable) Then
        $Executeable = $ShellCMD[$i] & $Executeable
        $bExecuteableFound = True
    EndIf
Next

And this will select the first valid location found in the list (might even be better, why waste time searching for network locations (which can be time consuming), if we've already found a valid file location):

For $i = 0 To UBound($ShellCMD) - 1
    If FileExists($ShellCMD[$i] & $Executeable) Then
        $Executeable = $ShellCMD[$i] & $Executeable
        $bExecuteableFound = True
        ExitLoop
    EndIf
Next
Link to comment
Share on other sites

  • 1 month later...

It loops through the possible locations, and if it has found found then it exits the loop...

This will select the last valid location found (as in the example above):

For $i = 0 To UBound($ShellCMD) - 1
    If FileExists($ShellCMD[$i] & $Executeable) Then
        $Executeable = $ShellCMD[$i] & $Executeable
        $bExecuteableFound = True
    EndIf
Next

And this will select the first valid location found in the list (might even be better, why waste time searching for network locations (which can be time consuming), if we've already found a valid file location):

For $i = 0 To UBound($ShellCMD) - 1
    If FileExists($ShellCMD[$i] & $Executeable) Then
        $Executeable = $ShellCMD[$i] & $Executeable
        $bExecuteableFound = True
        ExitLoop
    EndIf
Next

Thank you for the explanation.. Sorry for my late reply.. I was on holiday.

Adjusting all my scripts now.

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
 Share

  • Recently Browsing   0 members

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