联网小工具

@echo off
set num=0
setlocal enabledelayedexpansion
for /f "delims=" %%i in (Config.ini) do (
    set /a num+=1
    set str=%%i
    if !num! equ 4 set adslpassword=!str:~9!
    if !num! equ 5 set adsluser=!str:~9!
)

rem 设置名称,帐号,密码
set adslname=连接
set retry=0

rem 断开连接
:redisconnect
Rasdial %adslname% /disconnect
for /f "delims=" %%i in (ipadd.txt) do (
    set ipadd=%%i
)

rem 延时5秒,-n后面的5代表5秒,可以自己修改.
ping %ipadd% -n 3
if %errorlevel%n NEQ 0 (
goto start_connect
)
set /a retry+=1
if %retry% GEQ 3 (
goto connect_exit
)
goto redisconnect

:start_connect
echo 宽带连接已断开......
set retry=0

rem 宽带连接
:reconnect
Rasdial %adslname% %adsluser% %adslpassword%
for /f "tokens=16" %%i in ('ipconfig /all ^| find /i "IPv4" ^| find /i "10"') do set gateway=%%i
set ipadd=%gateway:~0,-4%
echo%ipadd% >ipadd.txt

rem 延时10秒,-n后面的10代表10秒,可以自己修改.
ping %ipadd% -n 3
if %errorlevel% EQU 0 (
goto connect_exit
)
set /a retry+=1
if %retry% LSS 3 (
goto reconnect
)

:connect_exit
TIMEOUT /T 3
@echo on

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值