The first and the last look fine. The one in the middle can't be discussed because of missing details.
But the THIRD and LAST batch file has the ECHO is on because you didn't tell it what to ECHO so it echoed the state of echo.
Bob
When working directly with a cmd prompt this works.
setlocal
set DOMAIN=test
ECHO %DOMAIN%
test
when trying to do something similar in a cmd file
FOR /F "tokens=1,2,3,6" %%A in (output.txt) do (
:ECHO 1[%%A] 2[%%B] 3[%%C] 6[%%D]
IF "%%~D" == "" (
BREAK
) ELSE (
ECHO 6[%%D]
SET DOMAIN=%%D
ECHO %DOMAIN%
)
)
It returns this as output
C:\downloads\Needed_Initial_Information>(IF "test" == "" (BREAK) ELSE (
ECHO 6[test]
SET DOMAIN=test
ECHO
) )
6[test]
ECHO is on.
Why is my ECHO %DOMAIN% always blank?

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic