Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

September 22, 2004 12:00 AM

JSI Tip 8497. AuthSync.bat script makes your Windows Server 2003 PDC emulator the authoritative time server for your domain.

Windows IT Pro
InstantDoc ID #81864
Rating: (0)

I have scripted AuthSync.bat to configure your Windows Server 2003 PDC emulator as the authoritative time server for your domain.

The syntax for using AuthSync.bat is:

AuthSync Seconds withIP1 [WithIP2 WithIPn] [\\PDC]

Where:

Seconds is the number of seconds between each external time source synchronization event.

withIPx is the IP address of an external time source.

\\PDC   is the computer name of your Windows Server 2003 PDC emulator, if you run the script remotely.

Example:

AuthSync 900 192.5.41.41 192.5.41.209 \\JSI001

will cause my Windows Server 2003 PDC emulator, \\JSI001, to synchronize its' clock, using SNTP (Simple Network Time Protocol), with the the U.S. Naval Observatory, tock.usno.navy.mil (192.5.41.41) or ntp2.usno.navy.mil (192.5.41.209), every 15 minutes (900 seconds).

AuthSync.bat contains:

@echo off
setlocal
if {%2}

{} goto syntax set work=%1 set /a secs=1000000%1%%1000000 if "%work%" NEQ "%secs%" go to sece if %secs% LSS 1 goto sece set IP=%2 set IPOK=Y call :valip if "%IPOK%" EQU "N" goto ipe set IPL=%IP% set PDCNAME= :ASL if {%3}

{} goto doit set work=%3 shift if "%work:~0,2%" EQU "\\" goto PDC set IP=%work% call :valip if "%IPOK%" EQU "N" goto ipe set IPL=%IPL% %work% goto ASL :PDC if not {%3}=={} goto syntax set OK=N for /f "Tokens=*" %%p in ('ping -n 1 %work:~2%^|find /I "Pinging %work:~2%."') do ( set OK=Y ) If "%OK%" NEQ "Y" goto PDCNF set PDCNAME=%work%:doit call :doreg>nul 2>&1 endlocal goto :EOF :doreg reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config" /V AnnounceFlags /T REG_DWORD /D 5 /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config" /V EventLogFlags /T REG_DWORD /D 2 /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config" /V MaxNegPhaseCorrection /T REG_DWORD /D 4294967295 /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config" /V MaxPosPhaseCorrection /T REG_DWORD /D 4294967295 /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /V Log /T REG_DWORD /D 100 /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /V WriteLog /D "True" /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /V Type /D "NTP" /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /V NtpServer /D "%IPL%" /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpServer" /V Enabled /T REG_DWORD /D 1 /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient" /V Enabled /T REG_DWORD /D 1 /F reg add "%PDCNAME%HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient" /V SpecialPollInterval /T REG_DWORD /D %secs% /F goto :EOF :valip for /f "Tokens=1-4 Delims=." %%a in ('@echo %IP%') do ( call :valipn %%a %%b %%c %%d ) goto :EOF :valipn set /a cnt=0 :valipnl set /a cnt=%cnt% + 1 if %cnt% GTR 4 goto :EOF set /a num=1000%1%%1000 if "%num%" NEQ "%1" goto valipe if %num% GTR 255 goto valipe shift goto valipnl :valipe set IPOK=N goto :EOF :sece @echo AuthSync - Seconds is not valid endlocal goto :EOF :ipe @echo AuthSync - IP address is not valid endlocal goto :EOF :syntax @echo AuthSync Seconds withIP1 [WithIP2 WithIPn] [\\PDC] endlocal goto :EOF :PDCNF @echo AuthSync - PDC not found endlocal



Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.