批处理获取IP生成TXT文本的bat代码
程序员文章站
2022-04-29 12:10:35
第一种方法:复制代码 代码如下:@echo off <"%~f0" more +5 >tmp.vbs cscript //nologo /e:vbscript...
第一种方法:
@echo off
<"%~f0" more +5 >tmp.vbs
cscript //nologo /e:vbscript tmp.vbs %1>ip.txt
echo >nul && del tmp.vbs
goto:eof
set odom = wscript.getobject("http://www.duosc.com/ip.aspx")
do until odom.readystate = "complete"
wscript.sleep 200
loop
s=odom.documentelement.innertext
set re = new regexp
re.pattern="(\d+)\.(\d+)\.(\d+)\.(\d+)"
for each m in re.execute(s)
wscript.echo m
next
第二种方法:都是利用vbs代码
@echo off
echo 正在连接,请稍等...
>getip.vbs echo set odom=wscript.getobject("http://www.ip138.com/ip2city.asp"):do until odom.readystate="complete":wscript.sleep 200:loop:wscript.echo odom.documentelement.outertext:set odom=nothing
for /f "tokens=2,* delims=:" %%i in ('"cscript //nologo getip.vbs"') do echo 你的ip地址是: %%i %%j>ip.txt
del getip.vbs
复制代码 代码如下:
@echo off
<"%~f0" more +5 >tmp.vbs
cscript //nologo /e:vbscript tmp.vbs %1>ip.txt
echo >nul && del tmp.vbs
goto:eof
set odom = wscript.getobject("http://www.duosc.com/ip.aspx")
do until odom.readystate = "complete"
wscript.sleep 200
loop
s=odom.documentelement.innertext
set re = new regexp
re.pattern="(\d+)\.(\d+)\.(\d+)\.(\d+)"
for each m in re.execute(s)
wscript.echo m
next
第二种方法:都是利用vbs代码
复制代码 代码如下:
@echo off
echo 正在连接,请稍等...
>getip.vbs echo set odom=wscript.getobject("http://www.ip138.com/ip2city.asp"):do until odom.readystate="complete":wscript.sleep 200:loop:wscript.echo odom.documentelement.outertext:set odom=nothing
for /f "tokens=2,* delims=:" %%i in ('"cscript //nologo getip.vbs"') do echo 你的ip地址是: %%i %%j>ip.txt
del getip.vbs
上一篇: js 实现复选框只能选择一项的示例代码
下一篇: BootStrap 动态表单效果