cjdrew see post above.
and for Fawers,
Your code, if right, and it looks like it wasn't quite right - from my test anyway, but correcting it so it works, yes it would certainly pick up whatever is within the [] In this case he had an IPv6 address there, the IPv6 address for localhost. (I only found out recently that ::1 was the IPv6 address for localhost)
Fawers wrote:You made me curious. What exactly is "FrostedFlakes"?
That's the name of his computer.
If you do ping localhost, you will see the name of your computer
As to your code for grabbing the IP, did you try it?
It didn't quite work for me and I doubt it could've worked for you, as it was.
It has to be tokens=1-3 not tokens=1-2.
As an example -simplified- because it's to demonstrate. To grab the IP.
(I think ::1 is the equivalent of 127.0.0.1 in IPv6)
Code: Select all
C:\>for /f "tokens=1-3 delims=[]" %h in ("Pinging magnus [127.0.0.1] with 32 bytes of data:") do echo %i
C:\>echo 127.0.0.1
127.0.0.1
Code: Select all
C:\>for /f "tokens=1-3 delims=[]" %h in ("Pinging magnus [::1] with 32 bytes of data:") do echo %i
C:\>echo ::1
::1