Hi,
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.
RunAsAdmin()
UrlDownLoadToFile, http:\\timeserver.iix.net.il\, %A_ScriptDir%\$.time
If (ErrorLevel)
MsgBox Time Server is not available`nErrorLevel: %ErrorLevel%
else MsgBox Sync data received
ExitApp
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?
Thanks
NTP sync
Re: NTP sync
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:
Displayed is the time offset compared to your system's local time.
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%