这个是要分成两部分来写的,第一部分是自动获取和扫描,另一部分是自动修改。
前面出错实属本人粗心大意,已修正- @echo off
- for /f "tokens=2 delims=:" %%i in ('ipconfig /all^|findstr /c:"IP Address"') do set "oldip=%%i"
- for /f "tokens=2 delims=:" %%a in ('ipconfig /all^|findstr /c:"Default Gateway"') do (
- set "wg=%%a"
- for /f "tokens=1-3 delims=. " %%i in ("%%a") do (
- set "wd=%%i.%%j.%%k."
- for /l %%m in (1,1,255) do start /min ping /n 1 %%i.%%j.%%k.%%m
- )
- )
- arp -a|findstr "dynamic">ip.txt
- for /l %%i in (1,1,255) do (
- set "ip=%%i"
- if "%wd%%%i" neq "%wg:~1%" findstr "\<%wd%%%i\>" ip.txt>nul||goto next
- )
- :next
- netsh interface ip set address "本地连接" static %wd%%ip% 255.255.255.0 %wg:~1% 1 >nul
- echo 配置前ip为%oldip:~1%,配置后ip为%wd%%ip%
- echo 完成配置,请按任意键退出。
- pause>nul
复制代码
[ 本帖最后由 batman 于 2008-8-10 21:19 编辑 ] |