I just created a tiny simple script to synchronize the comptuer's date/time with an Internet Time Server...
It uses CMDTIME 3, a small cmd-line application which I posted here
As I say in that post,
I was looking for a way to synchronize my clock with an Internet Time Server, but the most of the utilities I found wanted to stay resident in the System Tray... Rather than synchonizing at given periods of time, for me it's enough to synchronize the clock once at Windows startup (without having to have a dedicated program sitting on the tray all the time!)
This is the script I created to perform the synchronization:
; This script uses CMDTIME3 to synchronize the computer's date&time ; via Internet Time Servers. ; Get CMDTIME from: www.softshape.com/download ; The script writes the output of CMDTIME3 to a file CMDTIME.TXT ; in the machine's TEMP directory. ; Full name and path to cmdtime3 -> CUSTOMIZE AS NEEDED cmdtimepath=%ProgramFiles%\cmdtime\cmdtime3.exe ; Check if CMDTIME3.EXE exists in the given path ifnotexist, %cmdtimepath% { msgbox, Unable to find CMDTIME in:`n%cmdtimepath% exitapp } Loop { ; Delete previous CDMTIME.TXT temp file FileDelete, %temp%\CMDTIME.txt ; Run the CMDTIME3 command -> CUSTOMIZE AS NEEDED RunWait, cmd /c "%cmdtimepath%" /Q SYNC>%temp%\CMDTIME.txt,,hide ; Read the CMDTIME.TXT temp file FileRead, cmdtimeresult, %temp%\CMDTIME.txt ; If the file does not contain "Error" nor "Cannot", then everything was OK if cmdtimeresult not contains Error,Cannot break ; Otherwise, it probably means that the computer is still starting up... Sleep, 5000 }
Take into account that this script should NOT be used (as such) by users using a DIAL-UP connection to internet. The script assumes that an Internet connection is available.
For my purposes, I added a shortcut to this script in the Windows "Startup" program group, so my clock is synchronized at every boot.
If the Internet connection is not yet available when the script runs, it waits for 5 seconds and tries again...
These CMDTIME3 switches ( /Q SYNC ) work for me. You should customize those to suit your purposes (you can specify a variety of command-line options, including your favourite Internet Time Servers).
Another thing: probably administrator's rights are needed in order to change the system time... I'm not really sure...
regards
jordi