level 4
ipconfig 命令可以得到IP地址,用DOS管道,可以把结果输出到文本文件.
问题是,我不想要IPconfig 的那么多结果,只想要 IP地址那一行
有没有只显示本机IP地址的命令?
2010年08月05日 06点08分
1
level 1
将下述代码,复制到记事本中,保存为IPinfo.vbs 双击运行即可
dim a,b,c,ws
dim str(10)
Dim fso,f
Set fso=CreateObject("Scripting.FileSystemObject")
set ws=createobject("wscript.shell")
set a=ws.exec("ipconfig").stdout
b=a.readall
str(1)=mid(b,instr(b,"IP Address"))
str(2)=mid(str(1),1,instr(str(1),"S")-10)
str(2)=StrReverse(str(2))
str(1)=mid(str(2),1,instr(str(2)," ")-1)
str(1)=StrReverse(str(1))
Set f=fso.opentextfile("C:\ipinf.txt",2,True)
f.Write(str(1))
f.Close
ws.popup "OK!去C:\ipinf.txt 找IP地址吧!",2,"CyyCoiSh"
2010年08月05日 17点08分
3
level 1
ipconfig | find "IPv4" > ipaddress.txt
“ ”内是要搜索的字符串,加上开关 /i 可以忽略大小写
但是有个弊端就是,不能适用每台计算机,因为不同版本的windos,输入ipconfig之后,不一定ip地址是在IPv4这一行(XP就没有ipv4)
若有高手有更好的方法,请指点小生
2014年08月14日 01点08分
6