Page 1 of 1

Date & Time adjust

Posted: Wed Nov 25, 2009 8:34 am
by Ugo
Dear friends,
I need to adjust the time on windows, if i run this batch:

Code: Select all

net time /setsntp:ntp1.inrim.it
net stop w32time
net start w32time
the time is correctly updated.

But this code don't work:

Code: Select all

WinExec( "net time /setsntp:ntp1.inrim.it", SW_HIDE )
WinExec( "net stop w32time", SW_HIDE )
WinExec( "net start w32time", SW_HIDE )
any suggestion?

Many thanks in advance.

Date & Time adjust

Posted: Wed Nov 25, 2009 8:54 am
by Ugo
Dear friends,
This code work well:

Code: Select all

Function TimeAdj( cNtpServer )
DEFAULT cNtpServer := "ntp1.inrim.it"
WinExec( "net time /setsntp:"+cNtpServer, SW_HIDE )
ThreadSleep( 500 )
WinExec( "net stop w32time", SW_HIDE )
ThreadSleep( 500 )
WinExec( "net start w32time", SW_HIDE )
ThreadSleep( 500 )

Return Nil
From the return of this function and the windows time update is about 20/30 seconds.

Re: Date & Time adjust

Posted: Wed Nov 25, 2009 11:25 am
by MarcoBoschi
Ugo,
replace Winexec with Waitrun and remove
ThreadSleep( 500 ).

marco

Re: Date & Time adjust

Posted: Wed Nov 25, 2009 4:18 pm
by Ugo
MarcoBoschi wrote:Ugo,
replace Winexec with Waitrun and remove
ThreadSleep( 500 ).
Marco,
many thanks.