for /f in (filename) do (command)

for /f %i in (C:\ip.txt) do (ping %i -n 1 && echo %i 通 >>IP.txt || echo %i 不通 >>IP1.txt)

有返回写入ip.txt 没有写入ip1.txt