1 @echo off 2 cls 3 ::set NAME="本地连接" 4 set NAME="无线网络连接" 5 set IP=192.168.1.55 6 set MASK=255.255.255.0 7 set GATEWAY=192.168.1.1 8 set DNS1=42.120.21.30 9 set DNS2=114.114.114.114 10 11 echo. 12 echo 自动获取IP 请按 1 13 echo. 14 echo 手动设置IP 请按 2 15 16 set /p KEY= [您的选择是:] 17 if %KEY% == 1 goto ONE 18 if %KEY% == 2 goto TWO 19 20 :TWO 21 ECHO 您选择了手动设置IP。 22 ECHO. 23 netsh interface ip set address name=%NAME% static %IP% %MASK% %GATEWAY% 24 netsh interface ip set dns %NAME% %DNS1% index=1 25 netsh interface ip set dns %NAME% %DNS1% index=2 26 echo IP地址已经设定修改完毕,按任意键关闭此窗口 27 pause 28 exit 29 30 :ONE 31 ECHO 您选择了自动获取IP。 32 ECHO. 33 netsh interface ip set address name=%NAME% dhcp 34 netsh interface ip set dns %NAME% dhcp 35 36 ::netsh interface ip add dns %NAME% %DNS1% index=1 37 ::netsh interface ip add dns %NAME% %DNS1% index=2 38 39 echo IP地址已经设定修改完毕,按任意键关闭此窗口 40 pause 41 exit