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