NTP sync

Get help with using AutoHotkey and its commands and hotkeys

NTP sync

27 Feb 2015, 09:48


For my need NTPD doesn't do a good enough job, so u'm trying to write my own sync logic via ahk script.
I found several scripts that show they use UrlDownLoadToFile to receive data from an NTP server... but no matter what I do i get an error.


UrlDownLoadToFile, http:\\timeserver.iix.net.il\, %A_ScriptDir%\$.time

If (ErrorLevel)
MsgBox Time Server is not available`nErrorLevel: %ErrorLevel%
else MsgBox Sync data received


I've seen several scripts using that same line, but some uses port 13 other port 14 and others no port... while NTP port is 123.
Anyway, no matter what port (or no port) i'm using I get an error level 1.
I tried several NTP servers that work for me via NTPD or a scripted request thru a cmd like this:
RunWait, %comspec% /c ntpdate -q ntp.huji.ac.il >i:\ntpcmd.txt, c:\NTP service\bin, Hide

Any ideas why I can't get UrlDownLoadToFile to work?
User avatar
Posts: 1498
Joined: 19 Dec 2013, 11:16
Location: USA

Re: NTP sync

27 May 2015, 10:32

You seem to be using back-slashes instead of forward-slashes for the URL. Anyway, I don't think this method will work anymore.

Try this:

Code: Select all

RunWait, %ComSpec% /c w32tm /monitor /computers:time.nist.gov > Time.txt,, Hide
FileRead, Time, Time.txt
RegExMatch(Time, "\+(.*?)\s", Time)
MsgBox,, Time Offset,  %Time%
Displayed is the time offset compared to your system's local time.

Return to “Ask for Help”

Who is online

Users browsing this forum: crocodile, Descolada, PepeLapiu, QyouLimYT, Rohwedder and 60 guests