?
Solved

How to start time synchronize process via VB6?

Posted on 2011-03-11
10
Medium Priority
?
1,279 Views
Last Modified: 2012-05-11
Hi experts!

I’m interesting, how can I force programmatically via VB6 a computer with Windows 2008 Server, XP,Win7 Pro to synchronizer the clock with Internet server used already ready setting in Windows? Also will be good if I’m able to get notify that operation is finish, but this is not a must. I can simple wait 1 min. and then to pass my commands
.
0
Comment
Question by:dvplayltd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 15

Accepted Solution

by:
DonConsolio earned 2000 total points
ID: 35107602
If you have configured a valid time source you could try this:
(setting the time may require Admin rights)
Shell "c:\WINDOWS\system32\w32tm.exe /resync", vbHide

Open in new window

This should trigger a resync with your configured time sources.

To verify that the process has completed you may read the event log and check for event 35 from "W32Time" source or as you said just wait some time
0
 

Author Comment

by:dvplayltd
ID: 35107683
To Don Consolia

Hyym. This is possible solution, however I think there should be API which I may call and which are better manage with my own software.
0
 
LVL 15

Expert Comment

by:DonConsolio
ID: 35108713
There is no API i am aware of, and implementing your own NTP client
(like "Simple Network Time Protocol Client" http://www.dataman.ro/?page_id=39)
may be a bit of overkill for your application.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:dvplayltd
ID: 35110561
OK ..look that I'll take you first offer.

By the way, let me ask, can I use this tool to remove auto time synchro in Windows ?
I mean if I manual via GID intreface turn off time sinchor it appears that again it is done.

So question is: how to turn off auto time sycnhro of time inder XP and Win 7 ?
0
 

Author Comment

by:dvplayltd
ID: 35111173
And last clarigy question:

I found this decr:

/resync [{:ComputerName] [/nowait]|[/rediscover}] : Resynchronize the clock as soon as possible, disregarding all accumulated error statistics. If no computer is specified, the local computer will resynchronize. The command will wait for resynchronization unless the /nowait switch is used. Currently used time resources will be used unless /rediscover is used, which will force redetection of network resourced before resynchronization.

It look to me that I should use this, correct???

Shell "c:\WINDOWS\system32\w32tm.exe /resync /nowait", vbHide

I need set clock time to be done right away and after 10 sec. to contunie my operation with used correct current time
0
 
LVL 15

Expert Comment

by:DonConsolio
ID: 35111396
"/nowait – do not wait for the resynchronize to occur; return immediately. Otherwise, wait for the resynchronize to complete before returning."

If you use /nowait you have to "manually" wait or check the event log

use the optional "wait" argument (true/false)  and timeout (milisec.)

e.g.
Shell "c:\WINDOWS\system32\w32tm.exe /resync /nowait", vbHide , True, 5000
0
 
LVL 15

Expert Comment

by:DonConsolio
ID: 35111406
Sorry - copy/paste error :-)

of course you can't use /nowait if you wan to wait 5sec max

Shell "c:\WINDOWS\system32\w32tm.exe /resync", vbHide , True, 5000
0
 

Author Comment

by:dvplayltd
ID: 35113645
Hyyym. I think that use no wait and to start my next code after 5 sec. will be better. WHat will happen if for example file w32t,exe is missing or by some reason stop and wait a answer to question? I think that in this situation my code will block and stop ..
0
 
LVL 15

Expert Comment

by:DonConsolio
ID: 35114116
If the program can't be executed, Shell() will return
0
 

Author Closing Comment

by:dvplayltd
ID: 35115132
10x. I already put this in my software, it seems to work fine. Thank you very much!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question