Board logo

标题: [网络连接] 宽带批量拨号批处理BUG怎样完善? [打印本页]

作者: krsy    时间: 2011-1-26 02:05     标题: 宽带批量拨号批处理BUG怎样完善?

这个批处理第五个选项按照文本中的宽带账号密码链接宽带,密码会按照宽带密码文本的变化而变化、但是宽带账号还是开头的第一个账号不变、求解决方法
  1. @title 宽带账号批量连接检测批处理
  2. @echo off & setlocal enabledelayedexpansion
  3. set userfile=宽带账号.txt
  4. set passfile=宽带密码.txt
  5. set pppname=宽带连接
  6. set outfile=成功连接.txt
  7. :choose
  8. echo.&echo 本批处理实现以下功能:
  9. echo.&echo     1 - 创建 !pppname!(配合模拟按键实现)
  10. echo.&echo     2 - 测试固定的宽带账号及密码
  11. echo.&echo     3 - 宽带账号固定,密码从文本 %adslpass% 里提取逐一测试
  12. echo.&echo     4 - 宽带密码固定,账号从文本 %adsluser% 里提取逐一测试
  13. echo.&echo     5 - 宽带账号及密码均从以上文本里提取逐一测试
  14. echo.&echo     6 - 密码验证
  15. echo.&echo     0 - 退出批处理
  16. echo.&set /p choose=请输入你选择的序号并回车:
  17. if %choose% equ 0 exit
  18. if %choose% equ 1 goto :buildppp
  19. if %choose% equ 2 goto :user1pass1
  20. if %choose% equ 3 goto :user1passx
  21. if %choose% equ 4 goto :pass1userx
  22. if %choose% equ 5 goto :userxpassx
  23. if %choose% equ 6 goto :userxpassx2
  24. cls&echo.&echo 输入的序号有误,请重新选择!&set choose=&goto :choose
  25. :buildppp
  26. ::创建新宽带连接
  27. set vbs=buildppp.vbs
  28. (echo Set WshShell = CreateObject^("WScript.Shell"^)
  29. echo strCommandLine = "rasphone -a ""!pppname!"""
  30. echo WshShell.Run^(strCommandLine^)
  31. echo WScript.Sleep 1000
  32. echo WshShell.SendKeys "R"
  33. echo WScript.Sleep 30
  34. echo WshShell.SendKeys "{ENTER}"
  35. echo WScript.Sleep 30
  36. echo WshShell.SendKeys "{ENTER}"
  37. echo Set WshShell = Nothing
  38. )>"%vbs%"
  39. cscript //nologo "%vbs%"
  40. del "%vbs%"
  41. goto :exit
  42. :user1pass1
  43. echo.&set /p user=请输入宽带账号:
  44. echo.&set /p pass=请输入宽带密码:
  45. call :check1
  46. goto :exit
  47. :user1passx
  48. set user=改成固定的宽带账号
  49. call :check0
  50. for /f "tokens=*" %%a in ('type "%passfile%"') do (
  51.   if !end! equ 1 (set end=&goto :exit)
  52.   set pass=%%a&call :check1
  53. )
  54. goto :exit
  55. :pass1userx
  56. set pass=改成固定的宽带密码
  57. call :check0
  58. for /f "tokens=*" %%a in ('type "%userfile%"') do (
  59.   if !end! equ 1 (set end=&goto :exit)
  60.   set user=%%a&call :check1
  61. )
  62. goto :exit
  63. :userxpassx
  64. call :check0
  65. for /f "tokens=*" %%a in ('type "%userfile%"') do (
  66.   set user=%%a
  67.   call :check2
  68. )
  69. goto :exit
  70. :userxpassx2
  71. call :check0
  72. for /f "tokens=*" %%a in ('type "%userfile%"') do (
  73.   set user=%%a
  74.   call :check22
  75. )
  76. goto :exit
  77. :exit
  78. ::如果要连接最后一组成功的账号密码的话请取消下一行的前面两个冒号
  79. ::rasdial "!pppname!" !lastuser! !lastpass! >nul
  80. echo.&echo 所有操作完毕,按任意键退出&pause>nul&exit
  81. :check0
  82. rasdial|find "已连接">nul
  83. if !errorlevel! equ 0 for /f "skip=1 tokens=*" %%a in ('rasdial') do (rasdial "%%a" /d >nul&set pppname=%%a&goto :eof)
  84. goto :eof
  85. :check1
  86. echo.&set /p str=正在连接账号 !user!=!pass! <nul
  87. rasdial "!pppname!" !user! !pass! >nul
  88. rasdial|find "已连接">nul
  89. if !errorlevel! equ 0 (
  90.   echo [连接成功]
  91.   echo>>"%outfile%" !user!=!pass!
  92.   set lastuser=!user!
  93.   set lastpass=!pass!
  94.   set end=1
  95. ) else (echo.)
  96. rasdial "!pppname!" /d >nul
  97. goto :eof
  98. :check2
  99. for /f "tokens=*" %%b in ('type "%passfile%"') do (
  100.   if !end! equ 1 (set end=&goto :eof)
  101.   set pass=%%b
  102.   call :check1
  103. )
  104. goto :eof
  105. :check22
  106. for /f "delims=@" %%i in ('type "%userfile%"') do (
  107.   if !end! equ 1 (set end=&goto :eof)
  108.   set pass=%%i
  109.   set pass=!pass:~-6!
  110.   call :check1
  111. )
  112. goto :eof
复制代码

作者: krsy    时间: 2011-1-26 02:11

深夜没人啊、沙发我的
作者: q120072949    时间: 2011-1-26 18:24

研究ing
代码功底有待提高




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2