Windows cmd命令提示符重启网卡(网络适配器)

Windows cmd命令提示符重启网卡(网络适配器)

查询计算机上所有的网卡(包括虚拟网卡)

1
netsh interface show interface

操作网卡的指令

关闭网卡:

1
netsh interface set interface "要操作的网卡名称" disable

开启网卡:

1
netsh interface set interface "要操作的网卡名称" enable

以无线网卡WLAN为例,重启网卡(在管理员权限cmd窗口运行)

1
2
netsh interface set interface "WLAN" disable
netsh interface set interface "WLAN" enable

实例cmd脚本

脚本名:WLAN_Check.bat

脚本功能:当wifi断网后自动重启WLAN(网络适配器)

操作方式:将该脚本添加到任务计划程序,配置启动时运行,设置无限期每隔5分钟运行一次。配置后先手动运行一下后就不用再管了。

脚本内容:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@echo off

:Check
ping -n 2 www.baidu.com
if %ERRORLEVEL% == 0 goto Check 
if %ERRORLEVEL% == 1 goto RestartWLAN

:RestartWLAN
netsh interface set interface "WLAN" disable
netsh interface set interface "WLAN" enabled
Licensed under CC BY-NC-SA 4.0
最后更新于 Sep 19, 2025 13:40 +0800
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计