|Hi there! Scripting a program for work but I am new to batch files and cannot get this segment to work.|
for /f "tokens=* delims=" %%a in (computers.txt) do (
ping /n 1 %%a | find "Reply" >nul
if %errorlevel% == 0 goto reply
@echo %%a | Cannot ping
@echo %%a | Can ping
Intention: To get the list of computer names from 'computer.txt' and ping them replying, yes or no.
Problem: When I pull out the middle part in the loop and run it alone, it works fine. When I pull out the loop and run it alone, it works fine. When I combine it for some reason it just does not let me use %%a as a variable for a computer name.