@echo off

set POLLTIME=7f16f25
set TIME1=ptbtime1.ptb.de
set TIMESERVERS=ptbtime2.ptb.de ptbtime3.ptb.de 0.europe.pool.ntp.org ^
  1.europe.pool.ntp.org 2.europe.pool.ntp.org 3.europe.pool.ntp.org

echo ####### %0 #######

setlocal enabledelayedexpansion
set /a counter=1
for %%T in (
  %TIME1% %TIMESERVERS%
) do (
  echo adding Timeserver [ %%T ] with index [ !counter! ] to registry...
  reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
    /v "!counter!" /t REG_SZ /d "%%T" /f >nul
  reg add "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
    /v "!counter!" /t REG_SZ /d "%%T" /f >nul
  set /a counter+=1
)

echo setting poll time...
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient" ^
  /v "SpecialPollTimeRemaining" /t REG_SZ /d "%TIME1%,%POLLTIME%" /f >nul
reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\TimeProviders\NtpClient" ^
  /v "SpecialPollTimeRemaining" /t REG_SZ /d "%TIME1%,%POLLTIME%" /f >nul

echo setting server address...
reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\Parameters" ^
  /v "NtpServer" /t REG_SZ /d "%TIME1%,0x9" /f >nul
reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\W32Time\Parameters" ^
  /v "NtpServer" /t REG_SZ /d "%TIME1%,0x9" /f >nul

echo stopping time service ...
sc stop W32Time 1:3:3 1>nul

echo setting time service to automatic start ...
sc config W32Time start=auto

echo starting time service ...
sc start W32Time

echo ####### %0 #######