批处理命令设置IP

:: 设置IP地址
@set /p choice=请选择设置类型(1:wlan静态IP / 2:wlan自动获取IP / 3:以太网2静态IP / 4:以太网2动态IP):
echo.
if "%choice%"=="1" goto ip1
if "%choice%"=="2" goto ip2
if "%choice%"=="3" goto ip3
if "%choice%"=="4" goto ip4
goto main
:ip1
echo IP自动设置开始...
echo.
echo 正在设置IP及子网掩码
cmd /c netsh interface ip set address name="WLAN" source=static addr=192.168.0.200 mask=255.255.255.0 gateway=192.168.0.1 gwmetric=1
echo 正在设置DNS服务器
 
cmd /c netsh interface ip add dnsservers name="WLAN" address=192.168.0.1 index=1
cmd /c netsh interface ip add dnsservers name="WLAN" address=192.168.0.1 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
:ip3
echo IP自动设置开始...
echo.
echo 正在设置IP及子网掩码
cmd /c netsh interface ip set address name="以太网 2" source=static addr=10.48.116.234 mask=255.255.255.0 gateway=10.48.116.1 gwmetric=1
echo 正在设置DNS服务器
 
cmd /c netsh interface ip add dnsservers name="以太网 2" address=8.8.8.8 index=1
cmd /c netsh interface ip add dnsservers name="以太网 2" address=114.114.114.114 index=2
echo 设置完成
pause
exit
if errorlevel 2 goto main
if errorlevel 1 goto end
:ip4
echo IP自动设置开始....
echo.
echo 自动获取IP地址....
netsh interface ip set address name = "以太网 2" source = dhcp
echo 自动获取DNS服务器....
netsh interface ip set dns name = "以太网 2" source = dhcp
@rem 设置自动获取IP
echo 设置完成
pause
exit
if errorlevel 2 goto main
if errorlevel 1 goto end
:end 
--------------------- 

文章参考:链接丢失

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值