Downloaf IPINFO.ZIP, unzip it, and store IPA.EXE and IPN.EXE in a folder that is in your PATH.
NOTE: I discarded the IPINFO.EXE GUI.
Prior to having these tools, if I wanted to get my local computer's IP address, I would use a FOR command to parse @ping -n 1 %computername%, or Ipconfig /all.
Now, if I want the my computers IP address, I just parse ipa. If I want the IP address of another computer on my network, I just parse ipa \[computername\]:
for /f "Tokens=*" %%a in ('ipa SomeComputerName') do set IP=%%aNOTE: Both IPA.EXE and IPN.EXE return ERRORLEVEL 0 upon success, 1 on an error, and 2 on a syntax error.
If I want to return the computer name associated with an IP address on my network, I just parse ipn \[IPAdress\]:
for /f "Tokens=*" %%a in ('ipn SomeIPAaddress') do set name=%%aNOTE: If the network computer is a member of your domain, the format returned is ComputerName.DomainName, like JSI009.JSIINC.COM. If the network computer is NOT a member of your domain, the NetBIOS computer name is returned, like JSI009. If you always want just the NetBIOS computer name:
for /f "Tokens=1 Delims=." %%a in ('ipn SomeIPAddress') do set name=%%a
0 comments
Hide comments