Jump to content
antmar904

How to skip loop and go to next

Recommended Posts

antmar904
For $i = 0 To UBound($ComputerName) - 1
    $iFileExists = FileExists("\\" & $ComputerName[$i] & "\C$\Temp\Agent15\install_agent.bat")
    If Not $iFileExists Then
Next
FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Running installer")
;I'm doing more stuff if the bat file exist.
Next

Hi

I am looping through a txt file with computer names and checking if the bat file exists on the remote computer if it does not how do I skip this computer "$ComputerName[$i]" and move on to the next and start from the beginning from "For"?

Share this post


Link to post
Share on other sites
JLogan3o13

Why not just:

If FileExists("\\" & $ComputerName[$i] & "\C$\Temp\Agent15\install_agent.bat") Then
   ;Do something
EndIf

Then if the file doesn't exist, the PC is skipped.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
antmar904

I guess I'm ultimately trying to see if the pc is on before moving forward, I just thought of the ping.

Ping($ComputerName[$i])
    If @error Then
        ExitLoop
    EndIf

Will ExitLoop go back to the top of the loop and go through the rest of the computer names?

Share this post


Link to post
Share on other sites
JLogan3o13
Posted (edited)

I guess I am confused as to what you're after. If you ExitLoop, however many machines remain in the array will not be checked. If you then start the For Loop again from the beginning, unless you're doing something else to remove that computer from the array, you're going to exit again as soon as the array comes to this same PC.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JohnOne
2 minutes ago, antmar904 said:

I guess I'm ultimately trying to see if the pc is on before moving forward, I just thought of the ping.

Ping($ComputerName[$i])
    If @error Then
        ExitLoop
    EndIf

Will ExitLoop go back to the top of the loop and go through the rest of the computer names?

No.

Try ContinueLoop.

  • Like 1

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
antmar904

Thank you all again, It was ContinuLoop I was looking for!

Share this post


Link to post
Share on other sites
bernd670

Hello,

use ContinueLoop

For $i = 0 To UBound($ComputerName) - 1
    $iFileExists = FileExists("\\" & $ComputerName[$i] & "\C$\Temp\Agent15\install_agent.bat")
    If Not $iFileExists Then ContinueLoop

    FileWriteLine($LogFile, @MON & "/" & @MDAY & "/" & @YEAR & " - " & @HOUR & ":" & @MIN & ":" & @SEC & " Running installer")
    ;I'm doing more stuff if the bat file exist.
Next

 


greetings
bernd


I hacked 127.0.0.1 -> pcfred6.gif

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

×