Jump to content

Controll windows time / date - set to internettime and sync it


Recommended Posts

Hi

 

im looking for a way to change the time from my windows system with scrypt.

sometimes the set time is incorrect so that severl programs wont run.

The sollution is resync the nettime by klick on sync time from internet.

 

someone knows how to reallise this?

Link to post
Share on other sites

or how can i include the http://worldtimeapi.org/ api inside

    ; Set new system time
    $tNew = _Date_Time_EncodeSystemTime(8, 19, @YEAR, 3, 10, 45)
    If Not _Date_Time_SetSystemTime($tNew) Then
        MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage())
        Exit
    EndIf
    $tNew = _Date_Time_GetSystemTime()
    MemoWrite("New system date/time .....: " & _Date_Time_SystemTimeToDateTimeStr($tNew))
Link to post
Share on other sites
18 hours ago, svenjatzu said:

or how can i include the http://worldtimeapi.org/ api inside

Here is how you get the date and time out the web site :

#include <Constants.au3>
Local $String = BinaryToString(InetRead ("http://worldtimeapi.org/api/timezone/America/Toronto",1))
Local $Time = StringRegExp ($String,'datetime: (.+?)T(\d+:\d+:\d+)', $STR_REGEXPARRAYMATCH)
MsgBox ($MB_SYSTEMMODAL,"",$Time[0] & " " & $Time[1])

Now I will let you convert those to the right format.  Not a big deal...

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...