antmar904 Posted April 5, 2018 Posted April 5, 2018 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"?
Moderators JLogan3o13 Posted April 5, 2018 Moderators Posted April 5, 2018 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. "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!
JohnOne Posted April 5, 2018 Posted April 5, 2018 ExitLoop AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
antmar904 Posted April 5, 2018 Author Posted April 5, 2018 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?
Moderators JLogan3o13 Posted April 5, 2018 Moderators Posted April 5, 2018 (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 April 5, 2018 by JLogan3o13 "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!
JohnOne Posted April 5, 2018 Posted April 5, 2018 On 4/5/2018 at 3:36 PM, 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? Expand No. Try ContinueLoop. Danp2 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
antmar904 Posted April 5, 2018 Author Posted April 5, 2018 Thank you all again, It was ContinuLoop I was looking for!
bernd670 Posted April 5, 2018 Posted April 5, 2018 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 greetingsbernd I hacked 127.0.0.1 ->
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now