arp的输出用的2号句柄,这样写入文件试试:- setlocal enabledelayedexpansion
- echo 正在为您设置IP,请稍等......
- set /A "a=%RANDOM%%%250+3
- set /A "b=%RANDOM%%%250+3
- set /A "c=%RANDOM%%%250+3
- netsh interface ip set address name="本地连接" source=static addr=10.%a%.%b%.%c% mask=255.0.0.0
- :start
- set /A "num=%RANDOM%%%190+10"
- ping 10.1.1.%num% -n 1
- rem arp -a |find "10.1.1.%num%" &&goto start
- arp -a >test.log 2>&1
- %systemroot%\system32\arp.exe -a | %systemroot%\system32\find.exe "10.1.1.%num%"
- echo !errorlevel!
- if !errorlevel! equ 0 (
- goto :start
- )
- netsh interface ip set address name="本地连接" source=static addr=10.1.1.%num% mask=255.255.255.0 gateway=10.1.1.250 gwmetric=0 | find "IP地址已在网络上使用" &&goto start
- netsh interface ip set dns "本地连接" source=static addr=10.1.1.100 register=primary
- netsh interface ip add dns "本地连接" addr=8.8.8.8
- netsh interface ip set wins name="本地连接" source=static addr=10.1.1.100
- if %errorlevel% neq 0 goto start
复制代码
|