Continuing a for /l after you put a IF ELSE statement inside of it

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Jere299
Posts: 2
Joined: 25 Oct 2016 08:49

Continuing a for /l after you put a IF ELSE statement inside of it

#1 Post by Jere299 » 25 Oct 2016 08:52

Code: Select all

FOR /L %%i IN (1,1,30) DO @(
ping -n 1 -w 2 132.35.129.%%i << NUL
IF %errorlevel% == 0 (
   MD "\\132.35.129.%%i\c$\Test"
) ELSE (
   ECHO PASS
)
)



Basically, I'm trying to ping a workstation and if that ping is successful it makes a directory. But how do I continue the for /l after the if /else statement goes through?

Squashman
Expert
Posts: 4471
Joined: 23 Dec 2011 13:59

Re: Continuing a for /l after you put a IF ELSE statement inside of it

#2 Post by Squashman » 25 Oct 2016 09:04

Debug your program correctly.
If you are running it from the cmd prompt you should see an error appear.

Jere299
Posts: 2
Joined: 25 Oct 2016 08:49

Re: Continuing a for /l after you put a IF ELSE statement inside of it

#3 Post by Jere299 » 25 Oct 2016 09:20

Got it, thanks!

Post Reply