找到了...
你可以通过打开 http://www.aamailsoft.com/getip.php得到,第一次打开的话,缓存文件固定是getip[1].htm,那么可以节省一个FOR,不需要再DIR了
代码如下- setlocal EnableDelayedExpansion
- start http://www.aamailsoft.com/getip.php
- choice /d y /t 4 >nul //延迟4秒,自己看情况调整
- taskkill /f /im iexplore.exe //自己手动关闭或者是其它浏览器的话,自己改或者去掉
-
- for /f "skip=4 tokens=1* delims=" %%a in ('reg query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Cache\Paths" /v Directory') do (
-
- set str1=%%a
- set str2=!str1:*"=!
- set str3=!str2:~21!
- cd /d !str3!
- )
- for /f "delims=*" %%a in ('dir /a /s /b "%str3%\getip*"') do set ipfile=%%a
- for /f "usebackq delims=*" %%i in ("%ipfile%") do set ip=%%i
- echo 公网地址:%ip%
复制代码
[ 本帖最后由 caruko 于 2009-12-7 10:53 编辑 ] |