I know this an old thread but I've spent hours looking for an answer which didn't worked for me and this being one of the most popular answers to this question, I'll post it here.
I've noticed that the sintax when (
or )
is being used, is really strict. So using an editor like Sublime, or Notepad++, I've found one space char just next to one )
, in a 500 lines batch, that threw off the @echo off
statement.
In other words( * being used to visually represent a space at the end of line):
IF %randomvar% EQU 1 (*
goto DO
) ELSE (
goto DOELSE
)**
Either * or **, will mess @echo off
and will output every line of code to console.
Just make sure that you don't have any unnecesary chars at the end of lines.
Cheers