[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
原帖由 tireless 于 2009-4-23 00:37 发表
2楼的代码我测试过多次,是无效的。

因为 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections 下的值是二进制的,批处理没办法修改吧。所以可以先手工设置ie代理,然后 ...
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. ::3c标 01计数器  03(01)是(否)启用代理 FF行偏移量&h10(ip+prot字符串长度,变量cs)
  4. set "head=3C0000000100000003000000FF000000"
  5. set "regp="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections""
  6. set "pbkp=%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Connections\Pbk"
  7. call :input
  8. call :binary 0
  9. echo %head% %hex%x
  10. reg add %regp% /v %name% /t REG_BINARY /d %head%%hex% /f
  11. pause
  12. goto :eof
  13. :input
  14. for /f "delims=[]" %%i in ('findstr /b /e \[.*\] "%pbkp%\rasphone.pbk"') do (
  15. set/a num+=1
  16. set Connections!num!=%%i
  17. echo !num!.%%i
  18. )
  19. set/p name=选择宽带连接:
  20. if not defined Connections%name% goto input
  21. set name=!Connections%name%!
  22. set/p ip=代理服务器地址IP Address OR Domain Name:
  23. echo %ip%|findstr /b /e [1-9][0-9]*\.[0-9]*\.[0-9]*\.[0-9]*||call :toip||cls&&goto input
  24. set/p port=端口Port:
  25. set ip=%ip%:%port%
  26. echo %ip%|findstr /b /e [1-9][0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\:[0-9]*||cls&&goto input
  27. goto :eof
  28. :binary
  29. set var=!ip:~%cs%,1!||set hex=%hex:.=2E%&& set hex=!hex::=3A!&&goto :eof
  30. if %var%. GEQ 0 set /a var+=30
  31. set hex=%hex%%var%
  32. set /a cs+=1
  33. call :binary %cs%
  34. goto :eof
  35. :toip
  36. for /f "tokens=2 delims=[]" %%i in ('ping %ip%  /n 1^|findstr \[.*\]') do set ip=%%i
  37. :if not errorlevel 0 goto :eof
  38. goto :eof
复制代码

[ 本帖最后由 everest79 于 2009-5-4 00:51 编辑 ]

TOP

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. ::3c标 01计数器  03(01)是(否)启用代理 FF行偏移量&h10(ip+prot字符串长度,变量cs)
  4. set "head=3C0000000100000003000000FF000000"
  5. set "regp="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections""
  6. set ip=1.1.1.1:80
  7. ::上边设置代理IP与端口
  8. set name=ADSL
  9. ::上边设置宽连接名称
  10. call :binary 0
  11. reg add %regp% /v %name% /t REG_BINARY /d %head%%hex% /f
  12. pause
  13. goto :eof
  14. :binary
  15. set var=!ip:~%cs%,1!||set hex=%hex:.=2E%&& set hex=!hex::=3A!&&goto :eof
  16. if %var%. GEQ 0 set /a var+=30
  17. set hex=%hex%%var%
  18. set /a cs+=1
  19. call :binary %cs%
  20. goto :eof
复制代码
1

评分人数

TOP

返回列表