windows2003批量添加和导出所有ip

时间:2021-01-21 23:27:56

批量添加IP

在cmd命令行下运行:

FOR /L %i IN (130,1,190) DO netsh interface ip add address "本地连接" 192.168.1.%i 255.255.255.192

往“本地连接”中添加“192.168.1.130~192.168.1.190”的所有IP,且子网掩码都是255.255.255.192

导出所有IP

写一个批处理bat文件,如下内容,运行

@echo off

for /f %%i in (‘wmic computersystem get name^|findstr /i /v “name”‘) do set name=%%i&echo 计算计算机名称为%%i > %%i.txt
for /f “delims=: tokens=2″ %%j in (‘ipconfig^|findstr /i “IP Address”‘) do echo 计算机ip为%%j >> %name%.txt
echo 任务处理完毕任意键显示
pause&start %name%.txt