Skip to content

Instantly share code, notes, and snippets.

@GWuk
Last active January 26, 2016 06:56
Show Gist options
  • Save GWuk/2f9e52ccefbd8c747309 to your computer and use it in GitHub Desktop.
Save GWuk/2f9e52ccefbd8c747309 to your computer and use it in GitHub Desktop.
:: ----------------------------------------------------------------------------
:: setup Win7 NTP time sync
:: ----------------------------------------------------------------------------
:: general info: http://blogs.technet.com/b/askds/archive/2007/11/01/configuring-your-pdce-with-alternate-time-sources.aspx
:: stop service and reset
net stop w32time
:: reset (avoids problems)
w32tm /unregister
w32tm /register
:: set Max*PhaseCorrection to avoid problems after resume from longer standby
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config /v MaxPosPhaseCorrection /t REG_DWORD /d 0xffffffff /f
reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config /v MaxNegPhaseCorrection /t REG_DWORD /d 0xffffffff /f
:: start service
net start w32time
:: set automatic start
sc config w32time start= auto
:: enable automatic start, if not in domain
:: https://support.microsoft.com/en-us/kb/2385818
:: old: DOMAIN JOINED STATUS
sc qtriggerinfo w32time
:: new: IP ADDRESS AVAILABILITY
sc triggerinfo w32time start/networkon stop/networkoff
sc qtriggerinfo w32time
:: https://technet.microsoft.com/en-us/library/cc779560%28v=ws.10%29.aspx
:: no SpecialPollInterval, with fallback:
w32tm /config /update /manualpeerlist:"raspberrypi,0x8 pool.ntp.org,0xa" /syncfromflags:MANUAL
w32tm /resync
:: from now on, do not change time settings via Date+Time dialog, this sets SpecialPollInterval to 10 days and flaf 0x9 on ntp server
echo !! from now on, do not change time settings via Date+Time dialog (windows clocks) !!
:: ----------------------------------------------------------------------------
:: query status / debug
:: ----------------------------------------------------------------------------
w32tm /query /configuration
w32tm /query /source
w32tm /query /peers
w32tm /query /status /verbose
w32tm /monitor /computers:raspberrypi
w32tm /stripchart /computer:raspberrypi
:: ----------------------------------------------------------------------------
:: debug
:: ----------------------------------------------------------------------------
::w32tm /debug /enable /file:C:\Temp\w32time.log /size:10000000 /entries:0-300
::w32tm /resync
::w32tm /debug /disable
:: ----------------------------------------------------------------------------
:: set up SpecialPollInterval and MaxPhaseCorrection
:: ----------------------------------------------------------------------------
:: registry keys for max correction
:: net stop w32time
::reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config /v MaxPosPhaseCorrection /t REG_DWORD /d 0xffffffff /f
::reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\Config /v MaxNegPhaseCorrection /t REG_DWORD /d 0xffffffff /f
:: special poll:
::reg add HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient /v SpecialPollInterval /t REG_DWORD /d 10800 /f
:: net start w32time
:: SpecialPollInterval, with fallback:
::w32tm /config /update /manualpeerlist:"raspberrypi,0x9 pool.ntp.org,0xb" /syncfromflags:MANUAL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment