Date & Time adjust

Post Reply
User avatar
Ugo
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Date & Time adjust

Post 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.
Ciao, best regards,
Ugo
User avatar
Ugo
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Date & Time adjust

Post 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.
Ciao, best regards,
Ugo
User avatar
MarcoBoschi
Posts: 925
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy
Contact:

Re: Date & Time adjust

Post by MarcoBoschi »

Ugo,
replace Winexec with Waitrun and remove
ThreadSleep( 500 ).

marco
Marco Boschi
info@marcoboschi.it
User avatar
Ugo
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: Date & Time adjust

Post by Ugo »

MarcoBoschi wrote:Ugo,
replace Winexec with Waitrun and remove
ThreadSleep( 500 ).
Marco,
many thanks.
Ciao, best regards,
Ugo
Post Reply