Skip navigation

Q. How can a script cause a domain member to synchronize time with the domain's authoritative time server N times a day?

Using REG.EXE, built into Windows XP, Windows Server 2003, and later operating systems, or installed from the Windows 2000 Support Tools, I have scripted SyncNTPD.bat to cause a domain member to synchronize time with the domain's authoritative time server N times a day.

The syntax for using SyncNTPD.bat is:

\[CALL\] SyncNTPD TimesPerDay

Where TimesPerDay is the number of times per day that you wish the client to synchronize with the domain's authoritative time server.

SyncNTPD.bat contains:

@echo off
setlocal
if \{%1\}

\{\} goto err set /a tpd=%1 if \{%1\}

\{%tpd%\} goto AOK :err @echo Syntax: SyncNTPD TimesPerDay endlocal goto :EOF :AOK set wrk=%1 if "%wrk:~0,1%" EQU "0" goto err call :quiet>NUL 2>&1 net stop W32Time net start W32Time endlocal goto :EOF :quiet reg delete HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters /V Period /F reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters /V Period /T REG_DWORD /F /D %tpd% reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters /V GetDcBackoffMaxTimes /T REG_DWORD /F /D 0 reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Parameters /V GetDcBackoffMinutes /T REG_DWORD /F /D 1


Hide comments

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.
Publish