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

[网络工具] 批处理版普通宽带连接ADSL(PPPOE)创建工具

测试环境: WinXP SP3

系统向导方式 创建的连接项及其快捷方式的图标 是 netshell.dll 中由多个图标动态复合而成的, 系统通过检测宽带连接的状态操纵数个图标的复合组成选择, 以显示连接状态.
此工具创建新的连接, 会避开 rasphone.pbk 文件中已存在的条目, 按数字递增生成新的条目名称, 并在桌面生成一个快捷方式. 快捷方式的图标是 rasphone.exe 包含的一个图标, 不能动态指示连接状态.
  1. :: 涉及到 rasphone.pbk 文件的编码和 find 查找兼容编码的问题, 此工具生成的宽带连接名称不用中文.
  2. :: 关于两个键值 DialParamsUID, Guid, 本工具不生成, 代由系统自动生成.
  3. :: 打开 ncpa.cpl 刷新查看或 运行 rasdial ... 后, 系统会自动生成相关的键值.
  4. :: Guid 的键值也可用 MS 的工具 UUIDGEN 来生成, 下载: http://filediag.com/windows/process/Uuidgen.Exe.html
  5. :: PreviewUserPw=1 指定 提示名称, 密码和证书等.
  6. @echo off & setlocal enableDelayedExpansion
  7. set phoneBook="%AllUsersProfile%\Application Data\Microsoft\Network\Connections\Pbk\rasphone.pbk"
  8. set /a num=0& call :findNum num
  9. find "[PPPoE]" !phoneBook!>nul||set "num="
  10. >>!phoneBook! (
  11.   echo.&echo [PPPoE!num!]
  12.   for /f "delims=" %%a in (%~s0) do (
  13.     if /i "%%a"==":end:phoneBook" set getValue=N
  14.     if /i "!getValue!"=="Y" (echo %%a)
  15.     if /i "%%a"==":phoneBook" set "getValue=Y"
  16.   )
  17. )
  18. (set vbsfn="%temp%\scuttemp.vbs")
  19. >!vbsfn! (
  20.   for /f "delims=" %%a in (%~s0) do (
  21.     if /i "%%a"==":end:genVbs" set getValue=N
  22.     if /i "!getValue!"=="Y" (echo %%a)
  23.     if /i "%%a"==":genVbs" set "getValue=Y"
  24.   )
  25. )
  26. cscript //nologo !vbsfn!
  27. start Control netconnections& rem start ncpa.cpl
  28. start rasphone -d PPPoE!num!
  29. exit /b
  30. :findNum num rem 查找电话本中未用的条目标识数字
  31.   find "[PPPoE!%1!]" !phoneBook!>nul||exit /b
  32.   set /a %1+=1
  33. goto :findNum
  34. exit /b
  35. :genVbs
  36. Set WshShell = Wscript.CreateObject("Wscript.Shell")
  37. ' 创建一个快捷方式对象,其在桌面上设置相同的名字
  38. strDesktop = WshShell.SpecialFolders("Desktop")
  39. Set oShellLink = WshShell.CreateShortcut(strDesktop & "\\宽带连接!num!.lnk")
  40. ' 设置快捷方式的执行路径
  41. oShellLink.TargetPath = "rasphone.exe"
  42. oShellLink.Arguments = "-d PPPoE!num!"
  43. REM oShellLink.WindowStyle = 1              ' 运行方式
  44. REM oShellLink.Hotkey = ""                  ' 设置快捷方式的快捷键
  45. oShellLink.IconLocation = "rasphone.exe,0"  ' 设置文件夹快捷方式的图标路径
  46. oShellLink.Description = "连接宽带连接 PPPoE!num!"         ' 设置快捷方式的描述
  47. oShellLink.WorkingDirectory = "::{7007ACC7-3202-11D1-AAD2-00805FC1270E} :{BA126AD7-2166-11D1-B1D0-00805FC1270E}"   ' 起始位置
  48. oShellLink.Save
  49. :end:genVbs
  50. :phoneBook
  51. Encoding=1
  52. Type=5
  53. AutoLogon=0
  54. UseRasCredentials=0
  55. BaseProtocol=1
  56. VpnStrategy=0
  57. ExcludedProtocols=3
  58. LcpExtensions=1
  59. DataEncryption=8
  60. SwCompression=1
  61. NegotiateMultilinkAlways=0
  62. SkipNwcWarning=0
  63. SkipDownLevelDialog=0
  64. SkipDoubleDialDialog=0
  65. DialMode=1
  66. DialPercent=75
  67. DialSeconds=120
  68. HangUpPercent=10
  69. HangUpSeconds=120
  70. OverridePref=15
  71. RedialAttempts=3
  72. RedialSeconds=60
  73. IdleDisconnectSeconds=0
  74. RedialOnLinkFailure=1
  75. CallbackMode=0
  76. CustomDialDll=
  77. CustomDialFunc=
  78. CustomRasDialDll=
  79. AuthenticateServer=0
  80. ShareMsFilePrint=0
  81. BindMsNetClient=0
  82. SharedPhoneNumbers=0
  83. GlobalDeviceSettings=0
  84. PrerequisiteEntry=
  85. PrerequisitePbk=
  86. PreferredPort=
  87. PreferredDevice=
  88. PreferredBps=0
  89. PreferredHwFlow=0
  90. PreferredProtocol=0
  91. PreferredCompression=0
  92. PreferredSpeaker=0
  93. PreferredMdmProtocol=0
  94. PreviewUserPw=1
  95. PreviewDomain=0
  96. PreviewPhoneNumber=0
  97. ShowDialingProgress=1
  98. ShowMonitorIconInTaskBar=1
  99. CustomAuthKey=-1
  100. AuthRestrictions=632
  101. TypicalAuth=1
  102. IpPrioritizeRemote=1
  103. IpHeaderCompression=0
  104. IpAddress=0.0.0.0
  105. IpDnsAddress=0.0.0.0
  106. IpDns2Address=0.0.0.0
  107. IpWinsAddress=0.0.0.0
  108. IpWins2Address=0.0.0.0
  109. IpAssign=1
  110. IpNameAssign=1
  111. IpFrameSize=1006
  112. IpDnsFlags=0
  113. IpNBTFlags=0
  114. TcpWindowSize=0
  115. UseFlags=1
  116. IpSecFlags=0
  117. IpDnsSuffix=
  118. NETCOMPONENTS=
  119. ms_server=0
  120. ms_msclient=0
  121. MEDIA=rastapi
  122. Port=PPPoE5-0
  123. Device=WAN 微型端口 (PPPOE)
  124. DEVICE=rastapi
  125. PhoneNumber=
  126. AreaCode=
  127. CountryCode=1
  128. CountryID=1
  129. UseDialingRules=0
  130. Comment=
  131. LastSelectedPhone=0
  132. PromoteAlternates=0
  133. TryNextAlternateOnFail=1
  134. :end:phoneBook
复制代码

支持,能改成中国移动的WAP拨号吗?

TOP

rasphone.pbk
的移动WAP:
  1. [移动WAP]
  2. Encoding=1
  3. Type=1
  4. AutoLogon=0
  5. UseRasCredentials=1
  6. DialParamsUID=1905390
  7. Guid=AC778B0B473E7A4BAC63746F8E26D22F
  8. BaseProtocol=1
  9. VpnStrategy=0
  10. ExcludedProtocols=3
  11. LcpExtensions=1
  12. DataEncryption=8
  13. SwCompression=1
  14. NegotiateMultilinkAlways=0
  15. SkipNwcWarning=0
  16. SkipDownLevelDialog=0
  17. SkipDoubleDialDialog=0
  18. DialMode=0
  19. DialPercent=0
  20. DialSeconds=0
  21. HangUpPercent=0
  22. HangUpSeconds=0
  23. OverridePref=15
  24. RedialAttempts=0
  25. RedialSeconds=0
  26. IdleDisconnectSeconds=0
  27. RedialOnLinkFailure=0
  28. CallbackMode=0
  29. CustomDialDll=
  30. CustomDialFunc=
  31. CustomRasDialDll=
  32. AuthenticateServer=0
  33. ShareMsFilePrint=0
  34. BindMsNetClient=0
  35. SharedPhoneNumbers=0
  36. GlobalDeviceSettings=0
  37. PrerequisiteEntry=
  38. PrerequisitePbk=
  39. PreferredPort=COM5
  40. PreferredDevice=HUAWEI Mobile CMCC Modem
  41. PreferredBps=0
  42. PreferredHwFlow=0
  43. PreferredProtocol=0
  44. PreferredCompression=0
  45. PreferredSpeaker=0
  46. PreferredMdmProtocol=0
  47. PreviewUserPw=0
  48. PreviewDomain=0
  49. PreviewPhoneNumber=1
  50. ShowDialingProgress=0
  51. ShowMonitorIconInTaskBar=1
  52. CustomAuthKey=-1
  53. AuthRestrictions=288
  54. TypicalAuth=1
  55. IpPrioritizeRemote=1
  56. IpHeaderCompression=1
  57. IpAddress=0.0.0.0
  58. IpDnsAddress=0.0.0.0
  59. IpDns2Address=0.0.0.0
  60. IpWinsAddress=0.0.0.0
  61. IpWins2Address=0.0.0.0
  62. IpAssign=1
  63. IpNameAssign=1
  64. IpFrameSize=1006
  65. IpDnsFlags=0
  66. IpNBTFlags=1
  67. TcpWindowSize=0
  68. UseFlags=0
  69. IpSecFlags=0
  70. IpDnsSuffix=
  71. NETCOMPONENTS=
  72. ms_msclient=0
  73. ms_server=0
  74. MEDIA=serial
  75. Port=COM5
  76. Device=HUAWEI Mobile CMCC Modem
  77. ConnectBPS=7200000
  78. DEVICE=modem
  79. PhoneNumber=*98*1#
  80. AreaCode=
  81. CountryCode=1
  82. CountryID=1
  83. UseDialingRules=0
  84. Comment=
  85. LastSelectedPhone=0
  86. PromoteAlternates=0
  87. TryNextAlternateOnFail=1
  88. HwFlowControl=1
  89. Protocol=1
  90. Compression=1
  91. Speaker=1
  92. MdmProtocol=0
复制代码

TOP

路过顶一下~!!

TOP

楼主:
能写更详细的修改吗,我改了很多次,都没成功。。。。

TOP

这个有意思呢,竟然用批处理去弄!

TOP

楼主,能否用这个修改成新建一个VPN,也就是虚拟专用网络连接
1.名字:虚拟专用网络连接
2.桌面有同名快捷方式
3.属性里面的IP地址/域名可以在代码里自定义
4.自动重拨/重拨次数/重拨间隔时间 可以在代码里选择
谢啦!

TOP

楼主,我也跟楼上的兄弟需要的一样,建立一个vpn的链接,连接名称,IP地址可以自己定义的!
谢了!
BAT菜菜鸟!

TOP

可以添加用户吗  直接拨号

TOP

还可以设置成那些运行方式呢,要填什么数字
快捷键的设置能否举例

TOP

返回列表