I am not a programmer, and I do not have a network of computers or servers. It's just me and and a PC running Windows XP. I am working with a VBScript that makes changes to the system clock for parts of the script, and I need a way to reset the system clock properly after the script finishes the cycle. Initially, I stored the current time, made my time changes, and reset the clock to the prior saved time, but as the script cycled through its business, the initial time became several minutes off, so resetting the clock this way became impractical.
So, I began experimenting with having the script sync the system clock to an external server, i.e. time.nist.gov. My research led me to two ways to accomplish this: NET TIME and w32tm. From everything I could read, using NET TIME (i.e. net time /domain:time.nist.gov /set) should work, and work quickly and efficiently. But I cannot figure out why it doesn't work at all. In my script editor, I did not get any feedback, but once I put it into the command-prompt-window, I could see a message that comes up about not being able to find the domain controller for time.nist.gov. I have no idea what this means or why it doesn't work.
My second option is to use W32.TW /RESYNC, which does work, however, it takes about 16-18 seconds for this operation to complete. I had never noticed before, but this is also the case when you UPDATE NOW from the Internet Time tab on the system clock. Evidently, Windows does all kinds of stuff to ensure accuracy (even though I only have one server in the list) that takes forever. This is a problem for me because it causes all kinds of delays in an already long script. Other third-party clock sync software seem to do this in milliseconds, so I am assuming they just query the server, get the time, and change the clock - without all the overhead Windows seems to be adding. I am just trying to figure out how I can accomplish the same thing using VBScript. I guess my question is whether you know of any switches/settings that would reduce the time used by Windows in synching the system clock, or if you have an alternative way for me to get this done. NET TIME sounds perfect, but it doesn't seem to work. Is there a "second" clock in Windows I can latch onto, or somewhere I could store the current time, yet have it continue tick-tocking so I can get to it later (without the need for a external time source)?
Any help would be greatly appreciated!
NET TIMEis only for setting time from windows servers, not NTP servers, which is why it won't work in your case. – dsolimano Jan 31 '11 at 16:58ntpdate -q pool.ntp.org-- only a query -- takes 8.5 seconds on a generic Linux server with fast connection. It's not "overhead Windows seems to be adding", it's part of the protocol. – grawity Jan 31 '11 at 19:25time.nist.gov) directly, unless you absolutely need high accuracy. There'spool.ntp.orgfor mortals. – grawity Jan 31 '11 at 19:27