FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Date & Time adjust
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM

Date & Time adjust

Posted: Wed Nov 25, 2009 08:34 AM
Dear friends,
I need to adjust the time on windows, if i run this batch:
Code (fw): Select all Collapse
net time /setsntp:ntp1.inrim.it
net stop w32time
net start w32time
the time is correctly updated.

But this code don't work:
Code (fw): Select all Collapse
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
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM

Date & Time adjust

Posted: Wed Nov 25, 2009 08:54 AM
Dear friends,
This code work well:
Code (fw): Select all Collapse
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
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM

Re: Date & Time adjust

Posted: Wed Nov 25, 2009 11:25 AM

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

marco

Marco Boschi
info@marcoboschi.it
Posts: 283
Joined: Sat Oct 15, 2005 06:40 AM

Re: Date & Time adjust

Posted: Wed Nov 25, 2009 04:18 PM
MarcoBoschi wrote:Ugo,
replace Winexec with Waitrun and remove
ThreadSleep( 500 ).


Marco,
many thanks.
Ciao, best regards,

Ugo

Continue the discussion