电脑网卡设置脚本电脑用网卡如何设置

新建文本文档.txt,黏贴以下内容后,重命名为网卡.bat

cmd /c “cls

@ECHO OFF

CLS

color 0a

::##############################################################################################

goto MENU

:MENU

ECHO. =-=-=-=-=-=-=-=-=-=-=选择配置的网卡名称 =-=-=-=-=-=-=-=-=-=-=

ECHO.

ECHO. 1 无线网络连接(win7 无线) 3 WLAN (win10无线)

ECHO.

ECHO. 2 本地连接 (win7 有线) 4 以太网 (win10有线)

ECHO.

ECHO. 0 退 出

ECHO.

set /p=”请输入选择项目的序号:”<nul

</nul

set /p ID=

if “%id%”==”1” set networkcardname=无线网络连接&& goto SELECTIP

if “%id%”==”2” set networkcardname=本地连接&& goto SELECTIP

if “%id%”==”3” set networkcardname=WLAN&& goto SELECTIP

if “%id%”==”4” set networkcardname=以太网&& goto SELECTIP

if “%id%”==”0” exit

if not “%id%”==”0” goto MENU

::##############################################################################################

:SELECTIP

ECHO.

ECHO.

ECHO. =-=-=-=-=-=-=-=-=-=-=-=-=配置“%networkcardname%”网卡=-=-=-=-=-=-=-=-=-=-=-=-=

ECHO.

ECHO. 1 启用网卡并配置为内网192.168.0.x段ip 5 删除配置并关闭%networkcardname%

ECHO.

ECHO. 2 启用网卡并配置为外网192.168.1.x段ip 6 查看路由表

ECHO.

ECHO. 3 启用网卡并配置为内网2.193.80.x段ip 7 返回选择网卡

ECHO.

ECHO. 4 启用网卡并配置为外网10.10.13.x段ip 0 退 出

ECHO.

set /p=”请输入选择项目的序号:”<nul

</nul

set /p ID1=

if “%id1%”==”1” goto 192.168.0.x

if “%id1%”==”2” goto 192.168.1.x

if “%id1%”==”3” goto 2.193.80.x

if “%id1%”==”4” goto 10.10.13.x

if “%id1%”==”5” goto DELETEIP

if “%id1%”==”6” goto CHKROUTE

if “%id1%”==”7” goto MENU

if “%id1%”==”0” exit

if not “%id%”==”0” goto SELECTIP

::##############################################################################################

:10.10.13.x

set /a x=%random%%%253+2

set x1=10.10.13.%x%

netsh interface set interface %networkcardname% “enabled”

netsh interface ipv4 set address %networkcardname% static %x1% 255.255.255.0 10.10.13.1

netsh interface ipv4 set dns %networkcardname% static 223.5.5.5 validate=no

netsh interface ipv4 add dnsserver %networkcardname% 223.6.6.6 validate=no

ipconfig /all|findstr 10.10.13

ping -n 3 10.10.13.1|findstr TTL >nul && echo 信息:上网成功 && goto SELECTIP || echo 警告:ping10.10.13.1失败,请重新设置IP! && goto 10.10.13.x

ECHO.

ECHO.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:2.193.80.x

set /a x=%random%%%5+166

set x1=2.193.81.%x%

netsh interface set interface %networkcardname% “enabled”

netsh interface ipv4 set address %networkcardname% static %x1% 255.255.240.0

netsh WLAN connect China_168_nei

route -p add 32.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route -p add 10.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route -p add 2.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route -p add 172.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route -p add 59.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route -p add 188.18.18.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route -p add 192.168.8.0 mask 255.255.255.0 2.193.80.1 1>nul 2>nul

ping -n 3 2.193.80.1|findstr TTL >nul && echo 信息:ping2.193.80.1成功 && ipconfig /all|findstr 2.192.146 && goto SELECTIP || echo 警告:ping2.193.80.1失败,请重新设置IP! && goto 2.193.80.x

ECHO.

ECHO.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:192.168.1.x

set /a x=%random%%%253+2

set x1=192.168.1.%x%

netsh interface set interface %networkcardname% “enabled”

netsh interface ipv4 set address %networkcardname% static %x1% 255.255.255.0 192.168.1.1

netsh interface ipv4 set dns %networkcardname% static 223.5.5.5 validate=no

netsh interface ipv4 add dnsservers %networkcardname% 223.6.6.6 validate=no

ping -n 3 192.168.1.1|findstr TTL >nul && echo 信息:ping192.168.1.1成功 && ipconfig /all|findstr 192.168.1 && goto SELECTIP || echo 警告:ping192.168.1.1失败,请重新设置IP! && goto 192.168.1.x

ECHO.

ECHO.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:192.168.0.x

set /a x=%random%%%253+2

set x1=192.168.0.%x%

netsh interface set interface %networkcardname% “enabled”

netsh interface ipv4 set address %networkcardname% static %x1% 255.255.255.0

route -p add 32.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route -p add 10.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route -p add 2.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route -p add 172.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route -p add 59.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route -p add 188.18.18.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

ping -n 3 192.168.0.1|findstr TTL >nul && echo 信息:ping2.193.80.1成功&& ipconfig /all|findstr 192.168.0 && goto SELECTIP || echo 警告:ping192.168.0.1失败,请重新设置IP! && goto 192.168.0.x

ECHO.

ECHO.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:DELETEIP

echo 删除配置并关闭”%networkcardname%”网卡

netsh interface ipv4 set address %networkcardname% dhcp

netsh interface ipv4 set dns %networkcardname% dhcp

netsh interface set interface %networkcardname% “disabled”

route delete 32.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route delete 10.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route delete 2.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route delete 172.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route delete 59.0.0.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route delete 188.18.18.0 mask 255.0.0.0 2.193.80.1 1>nul 2>nul

route delete 192.168.8.0 mask 255.255.255.0 2.193.80.1 1>nul 2>nul

route delete 32.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route delete 10.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route delete 2.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route delete 172.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route delete 59.0.0.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route delete 188.18.18.0 mask 255.0.0.0 192.168.0.1 1>nul 2>nul

route delete 192.168.8.0 mask 255.255.255.0 192.168.0.1 1>nul 2>nul

ping -n 1 2.193.80.1|findstr TTL >nul && echo 警告:关闭网卡失败 && goto SELECTIP || echo 信息:关闭网卡成功 && goto SELECTIP

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:CHKROUTE

echo 查看路由表

route print -4

GOTO SELECTIP

::##############################################################################################

Published by

风君子

独自遨游何稽首 揭天掀地慰生平