0

Using a dos batch file, in windows XP, I want to save each Record Name and A (Host) Record from ipconfig /displaydns to a text file.

Instead of

 www.netword.com
 ----------------------------------------
 Record Name . . . . . : www.netword.com
 Record Type . . . . . : 1
 Time To Live  . . . . : 586924
 Data Length . . . . . : 4
 Section . . . . . . . : Answer
 A (Host) Record . . . : 127.0.0.1

I want it to show like this

 ----------------------------------------
 Record Name . . . . . : www.netword.com
 A (Host) Record . . . : 127.0.0.1

I want it to do this for each site in the ipconfig listing and save the results to a text (*.txt) file.

Thanks.

1
  • Sorry. I now see your logic.
    – UzuBlade
    Aug 16, 2015 at 4:06

1 Answer 1

1

Use | vertical line to pipe the ipconfig output into findstr command as follows:

ipconfig /displaydns | findstr /C:"Record Name" /C:"A (Host) Record" /C:"----"

Use > greater than sign to redirect all output to a text file named e.g. ipc.txt (note parentheses!):

> ipc.txt (ipconfig /displaydns | findstr /C:"Record Name" /C:"A (Host) Record" /C:"----")
3
  • Thank you JosefZ. I was trying to use ipconfig /[*] to clear the dns history on XP sp3. I tried blocking sites with the host file, but that simply made them go local. Something is trying to go to these (and other) sites. Record Name . . . . . : www.ainews.com Record Name . . . . . : ccas.clearchannel.com Record Name . . . . . : ads.webcash.nl Record Name . . . . . : ads.vegas.com [etc.] Your code will help me in digging them out of whereever they originate and stopping them from returning. Thank you JosefZ.
    – UzuBlade
    Aug 16, 2015 at 3:36
  • @UzuBlade I suspect you are on a wild goose chase... see this. Aug 16, 2015 at 3:54
  • I shall try to learn from that page. Maybe it is better not to be seriously irritated against some program that is trying to do unauthorized stuff when forming a conversation. I am reading your link. Thanks for the help. You are tolerant. I shall try to not ask in XY problem format, when I better understand it. Maybe "What have you tried" might not have been such a bad question to ask.
    – UzuBlade
    Aug 16, 2015 at 4:03

You must log in to answer this question.