Configuring an Internet Time Server on Windows Embedded Standards via Batch or Similar
I have a built-in Windows standard in which I do some installations and modifications specific to my company software as part of our installation process (it's all manual today). I am currently in the process of automating this procedure.
I want to set date and time properties -> internet time server in pool.ntp.org via batch file or similar. Command
w32tm
not recognized. I have tried using the command
net time /setsntp:pool.ntp.org
which returns
the command completed succefully.
...
Using the command
net time /querysntp
also returns
The current SNTP value is: pool.ntp.org
The command completed successfully.
But these changes are not reflected when I manually check them against date and time properties -> internet time server, even after restart. So I'm left wondering if the command I'm using works? Is there any other way to do this?
EDIT: The following .bat file works. Registry-only changes only added the server to the list and made it the default, but it didn't enable sync.
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers /v "0" /t REG_SZ /d "pool.ntp.org" /f
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers /ve /d "0" /f
NET TIME /setsntp:pool.ntp.org
source to share
Look in regedit for the following path:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers
Add your server to this folder as String Values - or you can change the MS provided defaults if you like. Make sure you have a "default" server (mine shows as 0) like the one Windows will use and at the top of the list in the time settings.
If you remove the default MS servers and add your own, make sure you have at least 2 servers listed, or when you try to access the Time & Date / Internet Time tab for hours, this is will crash and never display the list.
If you want to tweak any special ntp options take a look at this path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\W32Time
Restart the Windows Time service and you should be fine. There is no reason why you couldn't script this either through .bat or into a power shell.
source to share