@echo off
net view | find "\\">computername.txt
for /f "delims=\ " %%a in (computername.txt) do (
ping -n 1 %%a -4|findstr /i "TTL" >nul&&call :loop "%%a"
)>>所有在线的IP地址.txt
del computername.txt
pause&exit
:loop
for /f "tokens=2 delims=[]" %%b in ('ping -n 1 %~1 -4^|findstr "["') do echo "%%b"
转载于:https://my.oschina.net/u/3371661/blog/3056813