vendredi 21 octobre 2016

Skip to next in array for batch based off of IF condition

There is probably a simple bit of code but I cannot seem to find anything specific to what I need.

I have an array in a batch file & I am looking to use an IF statement as the condition to let the code continue or have it jump to the next in the array. The IF condition pretty much just checks to see if the C: drive is present. Is it possible w/o adding too may lines?

The ** ** is sudo code

SET Array[01]=Server1
SET Array[02]=Server2
SET Array[03]=Server3

FOR /F "tokens=2 delims==" %%s in ('SET Array[') do (
IF NOT exist \\%%s\c$ (
    ECHO Server %%s is not reachable & **JUMP TO NEXT IN ARRAY**
) else (
    **xcopy [source] [destination]** )

Aucun commentaire:

Enregistrer un commentaire