W
Wensi Peng
Hello,
I try to use %errorlevel% to control a batch program. When I use it in FOR
loop it does NOT give right error number after ping. I expect 0 with reply
from and 1 with request time out.
If ping runs out of FOR loop it gives correct expected error number.
Thanks for your help
Wensi
My example:
@echo off
ping -n 1 NotExistingServer
echo errorlevel %ErrorLevel%
for /f "tokens=1* delims=" %%i in (Servers.txt) do (
ping -n 1 %%i
echo errorlevel %ErrorLevel%
pause
)
server.txt
NotExistingServer
Server1
I try to use %errorlevel% to control a batch program. When I use it in FOR
loop it does NOT give right error number after ping. I expect 0 with reply
from and 1 with request time out.
If ping runs out of FOR loop it gives correct expected error number.
Thanks for your help
Wensi
My example:
@echo off
ping -n 1 NotExistingServer
echo errorlevel %ErrorLevel%
for /f "tokens=1* delims=" %%i in (Servers.txt) do (
ping -n 1 %%i
echo errorlevel %ErrorLevel%
pause
)
server.txt
NotExistingServer
Server1