:: 設置IP地址 set /p choice= 1.設置公司IP 2.IP自動獲取 您的選擇: echo. if "%choice%"=="1" goto ip1 if "%choice%"=="2" goto ip2 goto main :ip1 echo IP自動設置開始.... echo. echo 正在設置IP及子網掩碼 cmd /c netsh interface ip set address name="WLAN" source=static addr=192.168.1.* mask=255.255.255.0 gateway=192.168.1.* gwmetric=1 echo 正在設置DNS服務器 cmd /c netsh interface ip add dnsservers name="WLAN" address=8.8.8.8 index=1 cmd /c netsh interface ip add dnsservers name="WLAN" address=8.8.8.8 index=2 echo 設置完成 pause exit if errorlevel 2 goto main if errorlevel 1 goto end :ip2 echo IP自動設置開始.... echo. echo 自動獲取IP地址.... netsh interface ip set address name = "WLAN" source = dhcp echo 自動獲取DNS服務器.... netsh interface ip set dns name = "WLAN" source = dhcp @rem 設置自動獲取IP echo 設置完成 pause exit if errorlevel 2 goto main if errorlevel 1 goto end :test netsh inte***ce ip set address name = "WLAN" source = dhcp netsh inte***ce ip set dns name = "WLAN" source = dhcp netsh inte***ce ip set wins name = "WLAN" source = dhcp CHOICE /C YN /M "退出請按 Y,返回菜單請按 N。" if errorlevel 2 goto main if errorlevel 1 goto end :end
將標紅的部分替換爲你本身的IP,代碼保存爲 SetIP.bat ,雙擊運行,輸入 1或者2,便可將IP設置爲公司IP或者家裏的IP(自動獲取)。服務器