Log ping and date isn't working [closed]

Solution 1:

echo and ping are two commands separated by "&&". The way you wrote it, the second command (after "&&") is sent to the text file.

If you want both commands output to be sent to the text file, you can put them inside parentheses:

:START
(echo %date% %time% && ping -n 1 192.168.1.1) >> pingReport.txt 2>&1
(echo %date% %time% && ping -n 1 192.168.1.2) >> pingReport.txt 2>&1
(echo %date% %time% && ping -n 1 192.168.1.3) >> pingReport.txt 2>&1
(echo %date% %time% && ping -n 1 192.168.1.4) >> pingReport.txt 2>&1
goto START