1.

Solve : Updating window to the current date and time from time.nist.gov?

Answer»

Is there a way to update windows to the current DATE and time using time.nist.gov or time.windows.com? If I change the time and date, I would like this script to automatically update my computer to the current date and time without me setting it manually. This is what I currently have in place but doesn't set the correct date and time if altered:


w32tm /config /syncfromflags:MANUAL /manualpeerlist:time.nist.gov
net stop w32time && net start w32time
w32tm /config /update
RunDLL32.exe shell32.dll,Control_RunDLL timedate.cpl,,/Z Pacific Standard Time
w32tm /resync /nowait /rediscover
ping 127.0.0.1 -n 5 > nul

It is already in Windows.
A list of the Simple Network Time Protocol (SNTP) time servers that are available on the Internet. http://support.microsoft.com/kb/262680

The above link is a starting point to know more about Internet time sync.Here is a post of mine from SO about setting the time using a ntp server.

http://stackoverflow.com/a/13885418/891976I'm thinking the OP already has a script to retrieve and set the date/time. What's needed is a way to monitor a change and then run the script.

First you would need to check the local SECURITY policy and determine if such events are logged and if not, enable Privilege Use logging. Second would be to write a script to monitor the event log, wait for the event id to be posted and then initiate your script. The monitor script most likely be written in Powershell or VBScript but probably not batch.

If the date/time change is caused by a program, another approach would be to monitor the task list and when the program terminates, the monitor script would run your script to reset the date/time.

Question: why are you changing the date/time? Many Window functions (file/directory time stamping and the task scheduler among others) are affected by such an event.

This may help checking your local security policy.

Thanks for the replies. @Sidewinder - I'm running this script for our customers that have a login loop issue with our website which is normally caused by the date/time/timezone being incorrect. We deal with a lot of MECHANICS that just know how to fix cars, not computers. I'm creating a .exe that will help my customer support agents save an average of 30-40 minutes on the phone from having to manually do this with the customers. I'm most likely just going to have the Date and Time Properties pop-up for the customer for them to manually make the changes rather than make it automated. Too many issues with firewalls and access rights, so manual adjustments are the safest bet. Thanks again for your input, and if you have an easier solution, that would be most appreciated!



Discussion

No Comment Found