0

So I'm writing a batch file with absolute no knowledge about writing a batch. My goal is pretty simple. I want to execute arp -a and loop this. I want to save the IPv4 address to a variable. So I do this:

@echo off
for /f %%i in ('arp -a') do (
    set ipAddr=%%i
    echo Test: %ipAddr%
)

But this shows me multiple lines with Test: , nothing else. It looks like the variable is not filled properly. So I removed @echo off just to test and it returns me this:

C:\Users\rs\Desktop>(
set ipAddr=someIpAddrHere
 echo Test:
)
Test:

So I can see the IP address in the command, but in the output it's empty. What is wrong here?

roemel
  • 3,247
  • 4
  • 29
  • 52

0 Answers0