Question

I've created a batch script to read IP addresses or hostnames from a file, and feed them to nslookup, however when I run the script, it says that the system did not find the file.

What am I doing wrong?

Here's the code:

@echo off
setlocal enableextensions enabledelayedexpansion
if exist hostnames.txt del hostnames.txt
for /F %%A in (%1) do nslookup %%A >> hostnames.txt

Thanks in advance

No correct solution

OTHER TIPS

I wrote something similar. This works (you can remove the pause):

REM @echo off
del nslookup.txt 2>nul
pause
for /f "delims=" %%a in (c:\tools\server.txt) do NSLOOKUP %%a >> c:\tools\nslookup.txt

Results in txt file:

Name:    server1.XXXX.com
Address:  xxx.XX.XXX.XXX

Server:  server2.XXXX.com
Address:  xxx.XX.XXX.XX

etc.

Try this command.

:loop
 c:\windows\system32\nslookup.exe domainname >>D:\test\Hostname.txt
 timeout /t 300
goto loop
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top