Share via

bat script help

kzoord1 21 Reputation points
2021-12-10T11:43:56.51+00:00

Hi. I need help with a bat script, if someone can, please answer.

I have to do a bat script wchich will download pc names from txt file to array X and then make a nslookup with name from txt and when return ip adress then save it to next txt file wchich will have pc name and ip adress.

Thank you in advice.

Azure Batch
Azure Batch

An Azure service that provides cloud-scale job scheduling and compute management.

0 comments No comments

Answer accepted by question author

  1. shiva patpi 13,376 Reputation points Microsoft Employee Moderator
    2021-12-11T07:14:59.41+00:00

    Hello @kzoord1 ,
    Can you try this out?

    @Echo off
    set OUTPUTFILE=output.txt
    set lookup=hostnames.txt
    FOR /F %%i in (%lookup%) do (
    FOR /F "skip=3 delims=: tokens=2" %%j in ('echo(^|nslookup %%i') do @Echo %%i %%j >> %OUTPUTFILE%
    )

    I think you don't need to store in the array variable X as we can directly read from text file and we can push the output to another text file.

    Was this answer helpful?

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.