Hope someone can help. I have been struggling with printing out the IPv4 addresses of a domain specified by a user. I have managed to get it to print out one IPv4 address for a domain name however for example: microsoft.com has multiple IPv4's addresses however I can only get it to print out 1.
Thank you!
@echo off
setlocal EnableDelayedExpansion
set directory=%~1
if "%directory%"=="" (
:menu
echo Welcome to Domain Name Lookup
echo Please select the option you want to proceed:
echo 1. Input a domain name
echo 2. Quit from the program
choice /c 12 /n /m "Please select an option: "
if "!errorlevel!"=="1" (
set /p domain=Please enter the domain name:
echo Performing DNS lookup for !domain!
echo -------------------
for /f "tokens=2" %%a in ('nslookup -type=A !domain! 2^>nul ^| findstr /C:"Address"') do (
echo Domain: !domain!
echo Address: %%a
)
I've tried to change Address to Addressess as it appears in nslookup but was unsuccessful. I've attached an image of what my program displays, and also what it is supposed to display:
