Last month, my task was to write a script to detect the ip address of a hardware device having only the MAC address of the device. This time, I need to the script using DOS batch scripting. Here is the scirpt I wrote:
echo OFF
echo SCANNING NETWORK....
ipconfig | find "IP Address" > ~ip01.txt
for /f "tokens=1-2 delims=:" %%i in (~ip01.txt) do echo %%j> ~ip02.txt
for /f "tokens=1-3 delims=." %%i in (~ip02.txt) do echo %%i.%%j.%%k> ~ip03.txt
echo .....
for /f %%i in (~ip03.txt) do call :PING %%i
echo None > ipaddress.txt
arp -a | find "%1" > ip1.txt
for /f %%i in (ip1.txt) do echo %%i > ipaddress.txt
del ~ip01.txt ~ip02.txt ~ip03.txt ip1.txt
goto :EOF
:PING
for /L %%x in (1,1,254) do echo %1.%%x & ping -n 1 -w 50 -i 6 %1.%%x | find "Reply" && echo %1.%%x
Subscribe to:
Post Comments (Atom)
1 comment:
This is great info to know.
Post a Comment