jeudi 23 juillet 2020

Within a batch file, how can one break out of nested if statements if one criteria is met, but not the surrounding for loop?

Here's what I have...

For /F %%A In ('Type "C:\List.Of.PCs.txt"') Do @(
  Set PC=%%A
  For /F %%B In ('Dir "C:\Users" /B') Do @(
    Set USR=%%B
    If "!USR!" Neq "AAA" (
      If "!USR!" Neq "ABC" (
        If "!USR!" Neq "CDE" (
          If "!USR!" Neq "DEF" (
            [28 more if statements]
            Dir "\\!PC!\C$\Users\!USR!\AppData\Local\Temp\Logs\File.To.Find.Log" >Nul 2>Nul
            If "%ErrorLevel%" Equ "0" Echo File found on !PC! for !USR! >"C:\Results.txt"
          )
        )
      )
    )
  )
)

The goal is to break out of all those if statements if only one of them is satisfied, then start over with the outer-most for loop. Is this possible? If so, how the heck is that done? Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire