JSI Tip 10042. How can a script determine the source of information that the DNS server uses to start?

When the DNS Server service starts, it can get it's information from a BIND-style file named Boot, from the registry, or from Active Directory.

I have scripted BootMethod.bat to return the DNS start method.

The syntax for using BootMethod.bat on your DNS server is:

\[Call\] BootMethod Code \[X\]


Code is a call directed environment variable that will contain:

     0 - Unknown

     1 - Use the BIND-style file at %SystemRoot%\System32\DNS\Boot. If some information is missing, check the registry.

     2 - Use information from the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS registry sub-key.

     3 - Use Active Directory, and use the registry for missing information.

X    is an optional parameter that causes BootMethod.bat to use the DNSCMD.EXE
 tool instead of the REG.EXE tool.
NOTE: The BootMethod Value Name used in this script replaces the EnableRegistryBoot Value Name used in Windows NT.

BootMethod.bat contains:

@echo off
if \{%1\}

\{\} @echo Syntax: BootMethod Code \[X\]&goto :EOF setlocal set Code=0 if \{%2\}

\{\} goto RegRead set line= 0 for /f "Tokens=2 Delims==" %%a in ('dnscmd /info^|FIND /i "fBootMethod"') do ( set line=%%a ) set Code=%line:~1,1% endlocal&set %1=%Code% goto :EOF :RegRead set key=HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters call :quiet endlocal&set %1=%Code% goto :EOF :quiet For /f "Tokens=1,3" %%a in ('REG QUERY %key% /V BootMethod^|FIND /i "BootMethod"') do ( set Code=%%b )

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.