Date & Time adjust

Date & Time adjust

Postby Ugo » Wed Nov 25, 2009 8:34 am

Dear friends,
I need to adjust the time on windows, if i run this batch:
Code: Select all  Expand view
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  Expand view
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

Postby Ugo » Wed Nov 25, 2009 8:54 am

Dear friends,
This code work well:
Code: Select all  Expand view
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
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Re: Date & Time adjust

Postby MarcoBoschi » Wed Nov 25, 2009 11:25 am

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

marco
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Date & Time adjust

Postby Ugo » Wed Nov 25, 2009 4:18 pm

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


Marco,
many thanks.
Ciao, best regards,
Ugo
User avatar
Ugo
 
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests