Coming from Linux I'm fighting with a really basic problem with batch scripting on windows. On a LAN a network drive needs to be remapped based on a device MAC address. Finding it's IP can be achieved with this little script
@echo off
for /L %%a in (1,1,254) do @start /b ping 192.168.1.%%a -n 2 > nul
ping 127.0.0.1 -n 3 > nul
arp -a | find /i "01-00-5e-7f-ff-fa"
Gives me the following line based on a search for 01-00-5e-7f-ff-fa
192.168.135.3 01-00-5e-7f-ff-fa static
How can I extract/save the IP 192.168.135.3
in a variable called ASSIGNED_IP
to map the device as drive Y like:
net use drive Y /delete
net use Y: \\%ASSIGNED_IP%\files
What I've tried without luck: Using a FOR loop for assigning the result as suggested here further using the substring method as explained here