Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

All the way through the 2000+ sites that need to be added to it. I want the batch file to add the zone, add a host of, and then do the same thing for,, 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

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

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 . They have ideas for most everything you might encounter. – djangofan Nov 11 '11 at 17:36

Your Answer


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.