JSI Tip 10157. How can I retrieve the DNS name of a domain controller from the registry?

A good place to determine the DNS name of a domain controller in a Startup script is from the DCName Value Name, a string data type, at the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Group Policy\History key.

If your script, using REG.EXE, built into Windows XP, Windows Server 2003, and later operating systems, or installed from the Windows 2000 Support Tools, contains:

set key="HKLM\Software\Microsoft\Windows\CurrentVersion\Group Policy\History"
set DCName=NONE
for /f "Tokens=1,2*" %%a in ('reg query %key% /V DCName^|find /i "DCName"^|find "REG_SZ"') do (
 set DCName=%%c
The %DCName% environment variable might contains:


TAGS: Windows 8
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.