原帖由 tireless 于 2009-4-23 00:37 发表
2楼的代码我测试过多次,是无效的。
因为 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections 下的值是二进制的,批处理没办法修改吧。所以可以先手工设置ie代理,然后 ... -
- @echo off
- setlocal enabledelayedexpansion
- ::3c标 01计数器 03(01)是(否)启用代理 FF行偏移量&h10(ip+prot字符串长度,变量cs)
- set "head=3C0000000100000003000000FF000000"
- set "regp="HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections""
- set "pbkp=%ALLUSERSPROFILE%\Application Data\Microsoft\Network\Connections\Pbk"
- call :input
- call :binary 0
- echo %head% %hex%x
- reg add %regp% /v %name% /t REG_BINARY /d %head%%hex% /f
- pause
- goto :eof
- :input
- for /f "delims=[]" %%i in ('findstr /b /e \[.*\] "%pbkp%\rasphone.pbk"') do (
- set/a num+=1
- set Connections!num!=%%i
- echo !num!.%%i
- )
- set/p name=选择宽带连接:
- if not defined Connections%name% goto input
- set name=!Connections%name%!
- set/p ip=代理服务器地址IP Address OR Domain Name:
- echo %ip%|findstr /b /e [1-9][0-9]*\.[0-9]*\.[0-9]*\.[0-9]*||call :toip||cls&&goto input
- set/p port=端口Port:
- set ip=%ip%:%port%
- echo %ip%|findstr /b /e [1-9][0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\:[0-9]*||cls&&goto input
- goto :eof
- :binary
- set var=!ip:~%cs%,1!||set hex=%hex:.=2E%&& set hex=!hex::=3A!&&goto :eof
- if %var%. GEQ 0 set /a var+=30
- set hex=%hex%%var%
- set /a cs+=1
- call :binary %cs%
- goto :eof
- :toip
- for /f "tokens=2 delims=[]" %%i in ('ping %ip% /n 1^|findstr \[.*\]') do set ip=%%i
- :if not errorlevel 0 goto :eof
- goto :eof
复制代码
[ 本帖最后由 everest79 于 2009-5-4 00:51 编辑 ] |