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

Jerold Schulman

September 21, 2004

2 Min Read
ITPro Today logo

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 offsetlocalif {%2}
{} goto syntaxset work=%1set /a secs=1000000%1%%1000000if "%work%" NEQ "%secs%" go to seceif %secs% LSS 1 goto seceset IP=%2set IPOK=Ycall :valipif "%IPOK%" EQU "N" goto ipeset IPL=%IP%set PDCNAME=:ASLif {%3}
{} goto doitset work=%3shiftif "%work:~0,2%" EQU "\" goto PDCset IP=%work%call :valipif "%IPOK%" EQU "N" goto ipeset IPL=%IPL% %work%goto ASL:PDCif not {%3}=={} goto syntaxset OK=Nfor /f "Tokens=*" %%p in ('ping -n 1 %work:~2%^|find /I "Pinging %work:~2%."') do ( set OK=Y)If "%OK%" NEQ "Y" goto PDCNFset PDCNAME=%work%:doitcall :doreg>nul 2>&1endlocalgoto :EOF:doregreg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeConfig" /V AnnounceFlags /T REG_DWORD /D 5 /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeConfig" /V EventLogFlags /T REG_DWORD /D 2 /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeConfig" /V MaxNegPhaseCorrection /T REG_DWORD /D 4294967295 /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeConfig" /V MaxPosPhaseCorrection /T REG_DWORD /D 4294967295 /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeParameters" /V Log /T REG_DWORD /D 100 /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeParameters" /V WriteLog /D "True" /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeParameters" /V Type /D "NTP" /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeParameters" /V NtpServer /D "%IPL%" /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpServer" /V Enabled /T REG_DWORD /D 1 /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient" /V Enabled /T REG_DWORD /D 1 /Freg add "%PDCNAME%HKLMSYSTEMCurrentControlSetServicesW32TimeTimeProvidersNtpClient" /V SpecialPollInterval /T REG_DWORD /D %secs% /Fgoto :EOF:valipfor /f "Tokens=1-4 Delims=." %%a in ('@echo %IP%') do ( call :valipn %%a %%b %%c %%d )goto :EOF:valipnset /a cnt=0:valipnlset /a cnt=%cnt% + 1if %cnt% GTR 4 goto :EOFset /a num=1000%1%%1000if "%num%" NEQ "%1" goto valipeif %num% GTR 255 goto valipeshiftgoto valipnl:valipeset IPOK=Ngoto :EOF:sece@echo AuthSync - Seconds is not validendlocalgoto :EOF:ipe@echo AuthSync - IP address is not validendlocalgoto :EOF:syntax@echo AuthSync Seconds withIP1 [WithIP2 WithIPn] [\PDC]endlocalgoto :EOF:PDCNF@echo AuthSync - PDC not foundendlocal



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like