|I'm trying to return the first two octet of an ip address for comparison but it does not work for both locations. For instance, I'm in loc. A and my ip starts with 10.38.xx.xx, so the script indicates that I'm in loc. A. However, if I run this from loc. B whose IP begins with 10.9.xx.xx, it does not work because the prefix is always 10.9. (with extra dot) My question, is there anyway to make the script return only the first 2 octet of the ip address? i.e. if i ran the script from loc A or B, it should only return 2 octets i.e. xx.xx and nothing more. Also, when executed from loc B, it returns "your location cannot be determined" which is under the 3rd label in addition to returning "You are in loc. B".|
@echo off & setLocal EnableDELAYedeXpansion
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| find /i "IP"') do (
echo.Your IP Address is:!IP!
if not !IP!==!loca! call isB
echo.&echo.Your location is A
if not !IP!==!==!locb! call isOther
echo.&echo.Your location is B
echo.&echo.Your location cannot be determined.