Using WinIpCfg and Using FileRead to Grab the Contents of the Results
Keywords: WinIpCfg IP Address
Question:
I want to run WinIpCfg, then copy the contents of the results to the clipboard (I think it does it
automatically, or you could do it with a Ctrl-C), then save that in a file, and grab out the
Host Name, Physical Address, and IP Address. Can you help me set that up?
Answer:
Here's some sample code that extracts out the info you wanted:
myfile="c:\temp\test.txt"
keyword1="Host Name"
keyword2="Physical Address"
keyword3="IP Address"
hostname=""
physaddress=""
ipaddr=""
handle=FileOpen(myfile, "READ")
while 1
line=FileRead(handle)
if line == "*EOF*" then break
a=strindexnc(line,keyword1,0,@fwdscan)
b=strindexnc(line,keyword2,0,@fwdscan)
c=strindexnc(line,keyword3,0,@fwdscan)
if a!=0
hostname=line
else
if b!=0
physaddress=line
else
if c!=0
ipaddr=line
else
continue
endif
endif
endif
endwhile
fileclose(handle)
Message("Parsed Values:", "%hostname%%@crlf%%physaddress%%@crlf%%ipaddr%")
Article ID: W14408
Filename: Using WinIpCfg and Grabbing IP with FileRead.txt