解决WIFI断连问题
解决WIFI断连问题
将下列代码复制到*.bat(名字任意):
@echo off
setlocal ENABLEDELAYEDEXPANSION
set "netName=CMCC-YyAe-5G-FAST" #=号后填你的WIFI名
:loop
>nul ping baidu.com -n 1
if !errorlevel! equ 0 (
echo [%time%] ping is OK.
)
if !errorlevel! equ 1 (
echo [%time%] ping is Error.
>nul netsh wlan disconnect name=%netName%
>nul netsh wlan connect name=%netName%
)
>nul ping 127.0.0.1 -n 5
goto loop
运行此bat即可自动在断连时自动连接WIFI
但是这个bat会在前台运行,很容易会误关闭,于是又去网上搜索解决方法,经过多次搜索找到了方法: 将*.bat更改为:
@echo off
if "%1"=="hide" goto CmdBegin
start mshta vbscript:createobject("wscript.shell").run("""%~0"" hide",0)(window.close)&&exit
:CmdBegin
setlocal ENABLEDELAYEDEXPANSION
set "netName=" #“=”后填你的WIFI名
:loop
>nul ping baidu.com -n 1
if !errorlevel! equ 0 (
echo [%time%] ping is OK.
)
if !errorlevel! equ 1 (
echo [%time%] ping is Error.
>nul netsh wlan disconnect name=%netName%
>nul netsh wlan connect name=%netName%
)
>nul ping 127.0.0.1 -n 5
goto loop
:END
即可隐藏cmd窗口
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Hblog!