Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having a problem coding a .HTA file, and I really need some help. I've been searching all over the place and I can't seem to find what I need to add to this code to make it run. I'm trying to get the HTA script (running javascript) to, utilizing a .BAT file as well, pull information from a list of websites that need to be added to the Forward Lookup Zones of my DNS Server, and add a New Host (A) to the newly created Zone. I need the batch file to pull from a pre-created .txt file that has all the websites that need to be blocked. The .txt file says, for example:

website.number.1.com
website.number.2.com
website.number.3.com
website.number.4.com

All the way through the 2000+ sites that need to be added to it. I want the batch file to add the zone website.number.1.com, add a host of 127.0.0.1, and then do the same thing for website.number.2.com, website.number.3.com, and so on throughout the list. I know you can edit pretty much all of the DNS from the CMD prompt, but is there a way to make it go down the list and add all of the sites in the .txt file?

share|improve this question
    
Why not just directly load a custom zone file? –  Shane Madden Aug 17 '11 at 1:04

1 Answer 1

Assuming your list of zones is in zonelist.txt this will do what you want:

@echo off
for /f %%i in (zonelist.txt) do (
  dnscmd SERVER /ZoneAdd %%i /Primary
  dnscmd SERVER /RecordAdd %%i @ A 127.0.0.1
)

Using an hta file and Javascript is over-complicating the problem.

share|improve this answer
    
The job that was left to me was half-assed in an HTA file and he was asking me to make a .bat file. I tried putting that in but it doesn't seem to be working. I'm doing it on my non-privaliged account at the moment so that I can be sure that it's going to work and I'm not going to have to go over it again, because there's so many sites... I have a small list I'm testing it on, and when I do either command from CMD, it seems to work, but when I try to input it into a .bat file, it doesn't seem to be working. I can't even get it to pause after the script so I can see what it's doing. Any ideas? –  Joshua Cavalucci Aug 17 '11 at 2:31
    
Yes, look at dostips.com . They have ideas for most everything you might encounter. –  djangofan Nov 11 '11 at 17:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.