When you type IPCONFIG /ALL on a computer with multiple connections, multiple IP addresses are returned.
I have scripted LANIP.bat to return the IP address that matches a user specified mask, or masks.
The syntax for using LANIP.bat is:
LANIP IpMask \[IpMask ... IpMask\]
Where each IpMask uniquely identifies the IP address that you wish to enumerate.
If your local LAN ip addresses start with 192.168.0 or 192.168.1, you would use:
lanip 192.168.0 192.168.1
NOTE: If you knew that there were no nnn.192.168.xxx addresses, you could use lanip 192.168. instead. You can enumerate as many ranges as you wish by using the appropriates masks.
LANIP.bat contains:
@echo off If \{%1\}\{\} @echo Syntax LANIP IpMask \[IpMask ... IpMask\]&goto :EOF setlocal ENABLEDELAYEDEXPANSION set ipmask=%1 :loop shift if \{%1\}
\{\} goto find set ipmask=%ipmask% %1 goto loop :find for /f "Tokens=1* Delims=:" %%a in ('ipconfig /all^|Findstr /I /C:"IP Address"^|findstr "%ipmask%"') do ( set ip=%%b set ip=!ip: =! @echo !ip! ) ) endlocal
0 comments
Hide comments