[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[网络连接] 宽带自动拨号的BAT批处理为何出错?

从网上找了个宽带自动拨号的批处理,作用是根据用户名密码组合进行连续PPPOE拨号

我对批处理只看得懂简单的皮毛

我在批处理所在文件夹下建立了“D.bat”文件,内容是
USERNAME    PASSWORD
用户名    密码
第二个用户名     密码
。。。。。。。

但我用“Automatic dial”时,会出现


我对批处理只能看懂些皮毛,但我看:auto那段代码,自动拨号的时候屏幕应该显示以下内容的吧
Trying with username 账号 and password 密码
Error 691...Trying with next.

所以我的显示结果应该是根本就没有拨号吧,无奈本人实在不懂,不知道哪里有问题,请高手帮忙

根据作者的要求我将本地连接改成了LAN,宽带连接改成了RAS,本人操作系统为win7
  1. 代码开始
  2. @echo off
  3. rem initial setting
  4. color a
  5. title RAS Dialer
  6. setlocal EnableDelayedExpansion
  7. mode con:cols=72 lines=22
  8. :initial
  9. echo Disconnecting exist connection...
  10. rasdial ras /disconnect
  11. echo Please Wait...Network interface is initialazing...
  12. netsh interface set interface lan disable
  13. echo Local Area Connection is restarting...
  14. netsh interface set interface lan enable
  15. echo Local Area Connection has ready for DIAL...
  16. echo Please follow the step below...   
  17. :start
  18. color a
  19. echo  ----------------------------------------------------------------------
  20. echo  --------------------------Dialer For RAS------------------------------
  21. echo  ----------------------------------------------------------------------
  22. echo  Please choose method to Dial:
  23. echo  1. Automatic Dial
  24. echo  2. Manual Dial
  25. echo  x. Exit Dialer
  26. choice /c 12x /n /m Select: /t 10 /d 1
  27. if %errorlevel%==1 cls & goto auto
  28. if %errorlevel%==2 cls & goto manual
  29. if %errorlevel%==3 goto eof
  30. rem set /p se=Select:
  31. remif %se%==1 cls & goto auto
  32. rem if %se%==2 cls & goto manual
  33. rem if %se%==3 goto eof
  34. rem goto start
  35. :manual
  36. color a
  37. set x=
  38. set y=
  39. set z=
  40. echo  ----------------------------------------------------------------------
  41. echo  --------------------------Dialer For RAS------------------------------
  42. echo  ----------------------------------------------------------------------
  43. echo Please select your choice or enter your username and password...
  44. echo    x. Exit Dialer
  45. echo    m. Goto Main Menu
  46. echo Type "SPACE" at first character to instead "yhct2101"
  47. echo If PASSWORD is 8888 ...Just ignore them...
  48. set /p x=PPPoE Username:
  49. set z=%x%
  50. if "%x:~0,1%"=="x" goto eof
  51. if "%x:~0,1%"=="m" cls & goto start
  52. if "%x:~0,1%"==" " set z=yhct2101%x:~1,10%
  53. set /p y=PPPoE Password:
  54. if "%y:~0,1%"=="x" goto eof
  55. if "%y%"=="" set y=8888
  56. echo .............................................................
  57. echo Try with username "%z%" and password "%y%"
  58. echo .............................................................
  59. rasdial ras %z% %y% > nul
  60. set tt=%errorlevel%
  61. if !errorlevel!==0 (
  62.     color d
  63.     echo ______________________________________________________________________
  64.     echo                   PPPoE session create successful !
  65.     echo ______________________________________________________________________
  66.     echo Press X to EXIT the Dialer...
  67.     echo Press A to append username and password to Auto Dial Database...
  68.     choice /c xam /n /m "Exit(X) or Append(A) or MainMenu(M):"
  69.     if !errorlevel!==1 goto eof
  70.     if !errorlevel!==2 goto append
  71.     if !errorlevel!==3 cls & goto start
  72.     )
  73. color c
  74. echo Error %tt% occur !
  75. echo press any key to continue manual dial...
  76. pause>nul
  77. color a
  78. goto manual
  79. :auto
  80. cls
  81. echo Autodialer is trying connect with the database data......
  82. for /F "skip=142 tokens=1,2" %%i in (%~dp0\D.bat) do (
  83. echo Trying with username %%i and password %%j
  84. rasdial ras %%i %%j>nul
  85. if !errorlevel!==691 echo Error 691...Trying with next...
  86. if !errorlevel!==0 (
  87.     echo Success with username "%%i" and password "%%j" !
  88.     goto success
  89.            )
  90. if not !errorlevel!==691 set t1=!errorlevel! & goto err
  91. )
  92. echo All USERNAME and PASSWORD tried but faild to authenticate...
  93. echo Press any key back to main menu...
  94. pause>nul
  95. cls
  96. goto start
  97. :err
  98. color c
  99. echo -----------------------------------------------------------------------
  100. echo Error %t1% occur !!!
  101. echo Dialer will back to main menu...
  102. echo      For more help:
  103. echo      Type 'hh netcfg.chm'
  104. echo      In help:
  105. echo          1st.click Troubleshooting
  106. echo          2nd.click Error Messages
  107. echo          3rd.click %errorlevel%
  108. echo -----------------------------------------------------------------------
  109. echo Press any key back to main menu...
  110. pause>nul
  111. cls
  112. goto start
  113. :append
  114. echo
  115. cls
  116. echo user:%z% and pass:%y% will be append to the database...
  117. echo %z%    %y% >> %~f0
  118. echo Append Successful!
  119. pause > nul
  120. goto eof
  121. :success
  122. color d
  123. echo ______________________________________________________________________
  124. echo         PPPoE connection has Eastablished with AUTO mode!!!
  125. echo ______________________________________________________________________
  126. echo Press any key to EXIT the Dialer...
  127. pause>nul
  128. goto eof
  129. :eof
  130. endlocal
  131. exit
  132. USERNAME    PASSWORD
  133. 用户名    密码
  134. 第二个用户名     密码
  135. 。。。。。。
  136. 代码结束
复制代码

for /F "skip=142 tokens=1,2" %%i in (%~dp0\D.bat) do (
替换
for /F "skip=1 tokens=1,2" %%i in (%~dp0\D.bat) do (

142行  压根没那么多

我只是瞟了一眼  没细看 你试试 不行再说
困了。。

TOP

返回列表