本帖最后由 我不是是人 于 2015-6-11 13:56 编辑
回復樓主,小弟也是個新手,方法是有想到,不過有一個小小的問題,我電腦是英文版的...........
所以有些地方你需要修改一下(希望對你有幫助)- @echo off
- title 動態自動獲取IP設置
- set name="Local Area Connection"
- netsh interface ip set address name=%name% source=dhcp
- netsh interface ip set dns name=%name% source=dhcp
- for /f "tokens=14" %%a in ('IPConfig^| Find /i "IPv4 Address"') do (
- set IP=%%a
- )
- for /f "tokens=15" %%a in ('IPConfig^| Find /i "Subnet Mask"') do (
- set mask=%%a
- )
- for /f "tokens=13" %%a in ('IPConfig^| Find /i "Default Gateway"') do (
- set gw=%%a
- )
- for /f "tokens=15" %%a in ('IPConfig /all ^| Find /i "DNS Servers"') do (
- set dns=%%a
- )
- setlocal enabledelayedexpansion
- ipconfig /all>>qweasdzxc.txt
- set /a min=29,max=29
- for /f "tokens=1 delims= " %%a in ('more +%min% "qweasdzxc.txt"')do (
- if !min! equ %max% set dns2=%%a
- set /a min+=1
- )
- del qweasdzxc.txt
- netsh.exe interface ip set address %name% static %IP% %mask% %gw% 1
- netsh.exe interface ip set dns %name% static %dns%
- netsh.exe interface ip add dns %name% %dns2%
- netsh interface ip set wins name="%name%" source=static addr=none
- exit
复制代码 |