批处理代码列出不ping的IP地址
我正在使用以下代码从list.txt上的计算机名称列表列出IP地址,但是它们必须在列表中列出。如何编辑代码以显示这些不ping的IP地址?
@echo off
Echo Pinging list...
set ComputerList=list.txt
Echo Computername,IP Address>Final.csv
setlocal enabledelayedexpansion
for /f "usebackq tokens=*" %%A in ("%ComputerList%") do (
for /f "tokens=3" %%B in ('ping -n 1 -l 1 %%A ^|findstr Reply') do (
set IPadd=%%B
echo %%A,!IPadd:~0, -1!>>Results.csv
))
pause
list.txt包含以下内容:
结果
。
和 =“ https://i.sstatic.net/vi0fd.png” alt =“在此处输入图像说明”> ,
但它不会填充PCWindata103
I am using the code below to list ip addresses from a list of computer names on list.txt, but they have to be pinging to list. How can I edit the code to show these IP addressess that do not ping also?
@echo off
Echo Pinging list...
set ComputerList=list.txt
Echo Computername,IP Address>Final.csv
setlocal enabledelayedexpansion
for /f "usebackq tokens=*" %%A in ("%ComputerList%") do (
for /f "tokens=3" %%B in ('ping -n 1 -l 1 %%A ^|findstr Reply') do (
set IPadd=%%B
echo %%A,!IPadd:~0, -1!>>Results.csv
))
pause
list.txt contains the following:
and
Results.csv will populate
but it will not populate IP address for PCWINDATA103 because it is not pinging but I know an IP exists
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
强制自定义输出如果
findstr
找不到回复
(请注意“ Tokens = 3”):Force a custom output in case
findstr
doesn't findReply
(take care of "tokens=3"):