Onde você tem
do ping -n 1 %%a >nul
Isso está levando a saída de ping e jogando fora.
Eu acho que você quer
do ping -n 1 %%a >%LOGFILE%
Além disso, você está chamando uma região / sub-rotina inexistente (Logit)
@echo off
SET LOGFILE=MyLogFile.log
call :Logit >> %LOGFILE%
exit /b 0
:Logit
for /f "delims=" %%a in ( ' type "C:\Users\kelly\Desktop\Ping\computerlist.txt" ' ) do ping -n 1 %%a >nul && (echo %%a ok >> %LOGFILE% ) || (echo %%a failed to respond >> %LOGFILE% )
pause
(não testado)
~~ Edite com base no comentário do OP e agora tenha testado ~~
Acho que é isso que você está procurando:
@ECHO OFF
SET LOGFILE=logFile.txt
SET TEMP_FILE=temp.txt
SET PINGLIST=comps.txt
REM contatenate log file
echo. > %LOGFILE%
for /f "delims=" %%a in (%PINGLIST%) do (
REM do ping and store response - using a temp file because we care about the response more than once.
ping -n 1 %%a > %TEMP_FILE%
REM append response to log file
type %TEMP_FILE% >> %LOGFILE%
REM from: https://stackoverflow.com/a/8531199
REM check if ping determined the host is unreachable by searching the output
findstr /c:"Destination host unreachable" /c:"could not find host" %TEMP_FILE% > NUL
REM if the errorlevel is at least 1 (unsuccessful at finding string)
if errorlevel 1 (
REM then must have reached host
echo %%a is ok >> %LOGFILE%
) ELSE (
REM else, we found the string that sais we cannot reach the host
echo %%a is UNREACHABLE^! >> %LOGFILE%
)
REM cleanup
del %TEMP_FILE%
)
exit /b