It has taken me about 2 days worth of coding, and re-coding, but I think I finally got it.
Code:
regread, current, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\TimeZoneInformation, standardname
RegRead, Difference, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\%current%, Display
stringmid, count1, difference, 5,3
Stringmid, count2, difference, 9,2
urldownloadtofile, http://132.163.4.101:14, time.txt
FileReadLine, time, time.txt, 2
StringSplit, time, time, %A_Space%
stringreplace, date, time2, -,,all
stringreplace, time, time3, :,,all
if date is not number
{
msgbox There was a problem with the time synchronization`nPlease try again at a later time.
exitapp
}
today = 20%date%%time%
today += %count1%, hh
today += %count2%, mm
formattime, temp, %today%
stringmid, year, today, 3,2
stringmid, month, today, 5,2
stringmid, day, today, 7,2
stringmid, hour, today, 9,2
stringmid, min, today, 11,2
stringmid, sec, today, 13,2
FileAppend, date %day%-%month%-%year%`ntime %hour%:%min%:%sec%.00, %a_scriptdir%\temptime.bat ; Create the batch file that actually changes the time
loop, %USERPROFILE%\Local Settings\Temporary Internet Files\132.163*.*, 1, 1
{
filedelete, %A_LoopFileFullPath% ; if you don't do this, it will keep the same time as you last ran the program.
}
filedelete, %a_scriptdir%\time.txt
runwait, %a_scriptdir%\temptime.bat,, hide ;run it :)
FileDelete, %a_scriptdir%\temptime.bat ; start with a fresh file
Let me know if there is something that I could do better, easier, or whatever.
Side note:
this does not work with Jerusalem, or kuala, lumpur singapore. I will update that after I get a nap
