:: 设置IP地址set /p choice= 1.设置公司IP 2.IP自动获取 您的选择:echo.if "%choice%"=="1" goto ip1if "%choice%"=="2" goto ip2goto main:ip1echo 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=1echo 正在设置DNS服务器cmd /c netsh interface ip add dnsservers name="WLAN" address=8.8.8.8 index=1cmd /c netsh interface ip add dnsservers name="WLAN" address=8.8.8.8 index=2echo 设置完成pauseexitif errorlevel 2 goto mainif errorlevel 1 goto end:ip2echo IP自动设置开始....echo.echo 自动获取IP地址....netsh interface ip set address name = "WLAN" source = dhcpecho 自动获取DNS服务器....netsh interface ip set dns name = "WLAN" source = dhcp@rem 设置自动获取IPecho 设置完成pauseexitif errorlevel 2 goto mainif errorlevel 1 goto end:testnetsh inte***ce ip set address name = "WLAN" source = dhcpnetsh inte***ce ip set dns name = "WLAN" source = dhcpnetsh inte***ce ip set wins name = "WLAN" source = dhcpCHOICE /C YN /M "退出请按 Y,返回菜单请按 N。"if errorlevel 2 goto mainif errorlevel 1 goto end:end
将标红的部分替换为你自己的IP,代码保存为 SetIP.bat ,双击运行,输入 1或者2,即可将IP设置为公司IP或者家里的IP(自动获取)。