有需要者请把代码保存成横线中的文件名即可.
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 配置结束
-----------------------
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 配置结束
-----------------------