I am a BEGINNER STUDENT of Batch scripting. The problem I have is that I am able to retrieve a computer name from my LAN by pinging its IP address (see code below). However, I'm struggling to find an equally simple way of getting the IP address of a computer on my network when using the computer name. As far as I can see pinging the computer name only provides a MAC ID but no IP.
The reason I require this function is for a small batch script I'm writing which prompts the user for either an IP OR computer name for messaging (msg.exe) purposes. Subsequent configurations (TTL checks and registry key changes) explicitly require one or the other.
@echo off
for /f "tokens=1,2" %%a in ('ping -a 192.168.1.33 ^| find "Pinging"') do set compname=%%b >nul
echo Computer name is %compname%
echo.
pause