以前写的一个更换网络环境的小批处理(原创)

有需要者请把代码保存成横线中的文件名即可.

IP配置文件请自行修改
source=static addr=本机IP mask=子网掩码
set address name="网卡连接名" gateway=网关 gwmetric=0
set dns name="网卡连接名" source=static addr=DNS1 register=PRIMARY
add dns name="网卡连接名" addr=DNS2

使用效果为执行后按一键即可实现IP环境的更新与启用。



---------------------------
ip.bat
-----------------------------------

@echo off

type list.txt

choice /c 1230

if errorlevel 4 goto 0end

if errorlevel 3 goto 119

if errorlevel 2 goto 212

if errorlevel 1 goto 50

:119
echo 正在更改网关为119....
netsh -f 119.txt
goto end

:50
echo 正在更改网关为50....
netsh -f 50.txt
goto end

:212
echo 正在更改网关为212....
netsh -f 212.txt
goto end

:0end
echo 用户选择不改变
goto pus

:end
echo 网关更改完成
goto pus

:pus
pause
------------------------------

list.txt
--------------------------------
┏━━━━━━━━━━━━━━━━━━━━┓
┃ 网关选择                               ┃
┞────────────────────┦
│ 1.         192.168.1.50                │
├────────────────────┤
│ 2.         192.168.1.212               │
├────────────────────┤
│ 3.         192.168.1.119               │
├────────────────────┤
│ 0.         不做任何修改                │
└────────────────────┘
------------------------------
50.txt
-----------------------------
# ----------------------------------
# 接口 IP 配置        
# ----------------------------------
pushd inte***ce ip


# "本地连接" 的接口 IP  配置

set address name="本地连接" source=static addr=192.168.1.252 mask=255.255.255.0
set address name="本地连接" gateway=192.168.1.50 gwmetric=0
set dns name="本地连接" source=static addr=202.96.128.143 register=PRIMARY
add dns name="本地连接" addr=202.96.128.68 index=2
set wins name="本地连接" source=static addr=none


popd
# 接口 IP 配置结束


----------------------------
119.txt
----------------------------
# ----------------------------------
# 接口 IP 配置        
# ----------------------------------
pushd inte***ce ip


# "本地连接" 的接口 IP  配置

set address name="本地连接" source=static addr=192.168.1.252 mask=255.255.255.0
set address name="本地连接" gateway=192.168.1.119 gwmetric=0
set dns name="本地连接" source=static addr=202.96.128.143 register=PRIMARY
add dns name="本地连接" addr=202.96.128.68 index=2
set wins name="本地连接" source=static addr=none


popd
# 接口 IP 配置结束


--------------------------
212.txt
---------------------------
# ----------------------------------
# 接口 IP 配置        
# ----------------------------------
pushd inte***ce ip


# "本地连接" 的接口 IP  配置

set address name="本地连接" source=static addr=192.168.1.252 mask=255.255.255.0
set address name="本地连接" gateway=192.168.1.212 gwmetric=0
set dns name="本地连接" source=static addr=202.96.128.143 register=PRIMARY
add dns name="本地连接" addr=202.96.128.68 index=2
set wins name="本地连接" source=static addr=none


popd
# 接口 IP 配置结束


----------------------- 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值