timeserver script fixed

This commit is contained in:
Michael H.G. Schmidt 2023-04-18 21:19:19 +02:00
parent 78b4986578
commit 177a708468
2 changed files with 28 additions and 23 deletions

View File

@ -1,31 +1,36 @@
@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 #######
echo adding PTB time servers ...
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
/v "1" /t REG_SZ /d "ptbtime1.ptb.de" /f
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
)
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
/v "2" /t REG_SZ /d "ptbtime2.ptb.de" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
/v "3" /t REG_SZ /d "ptbtime3.ptb.de" /f
echo adding EUROPE ntp pool servers ...
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
/v "4" /t REG_SZ /d "0.europe.pool.ntp.org" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
/v "5" /t REG_SZ /d "1.europe.pool.ntp.org" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
/v "6" /t REG_SZ /d "2.europe.pool.ntp.org" /f
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers" ^
/v "7" /t REG_SZ /d "3.europe.pool.ntp.org" /f
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

View File

@ -1,6 +1,6 @@
@echo off
set %TOOLS%=%SystemDrive%\tools
set TOOLS=%SystemDrive%\tools
set ARG1=null
IF "%~1" NEQ "" set ARG1=%1