@echo off cls ::REM ***************************************************** ::REM B a t c h P r o g r a m m i n g S a m p l e ::REM from http://www.japan-page.net ::REM (C) 2002 John D. Seaman ::REM Copylefted, and released to the general Internet ::REM community, you may use, modify and release this ::REM at will as long as you retain this header. ::REM ***************************************************** ::REM DNS export script v.0.01b 2003.2.22 ::REM What this script does: ::REM Gets all DNS zones that W2K is authoritative for, dump the zone records to txt files. ::REM Purpose: track changes if needed, do offline scripted duplicate RR checks, etc. ::REM Requires t.exe from Texttools32 ::REM http://www.fireflysoftware.com/TEXTools/ ::REM Set focus DNS server here (input your W2K DNS server by IP) set _localdns=192.168.0.1 ::REM --------------------------------------- ::REM ----- No need to edit below here ------ ::REM --------------------------------------- ::REM Get a list of authoritative zones on our target DNS server dnscmd.exe %_localdns% /EnumZones >_localzn1.txt ::REM Clean up the output ::REM Extract the first column for /f "tokens=1,2*" %%i in (_localzn1.txt) do echo %%i >>_localzn2.txt ::REM Cull out header type _localzn2.txt | t cull 'Enumerated ' '127.in-addr.arpa ' >_localzn3.txt ::REM Extract broadcast domain type _localzn3.txt | t excl '255.in-addr.arpa' 1 100 > _localzn4.txt ::REM Extract completed successfully text type _localzn4.txt | t excl 'Command' 1 100 > _localzn5.txt copy _localzn5.txt _doit.log ::REM Cleanup del /q _localzn1.txt _localzn2.txt localzn3.txt _localzn4.txt _localzn5.txt >nul ::REM Call dnscmd, output a report for each domain found in a loop for /f %%i in (_doit.log) do call :processdomain %%i ::REM Optional: Make a zip file of today's files ::REM -> Requires local instal of Winzip 8.x or newer PLUS ::REM -> Optional Winzip command line extensions AND ::REM -> Add winzip install directory to the system path :: wzzip dns_export_%yy%.%mm%.%dd%.zip *.txt del /q _doit.log del /q *.txt ::REM --- END --- goto :EOF ::REM ----------------------- F U N C T I O N S ----------------------- ::REM Call dnscmd.exe on each domain :processdomain echo. echo Processing domain %1... echo. ::REM Put command into a variable here ::REM The only way to get the "@" to work from a batch file. :-) set _justdoit=%_localdns% /EnumRecords %1 @ dnscmd.exe %_justdoit% > %1.txt :EOF