Set local time

thenrich used Ask the Experts™
Using vb script how can I set the client side time to match the server from where the script resides. In this case it would be my domain controllers time I want to copy to all clients when they login.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2018
Distinguished Expert 2018
Is there any special reason that you want to do something manually in a logon script that
a. users don't have permissions to do anyway and that
b. is already implemented *by* *default* in an AD domain?
Kerberos requires that the time on server and clients is within a five minute interval; so domain members sync with the DC authenticating them, DCs sync with the PDC emulator, and the only machine you might need to configure manually once is the PDCe, by letting it sync with an external time source ( isn't that reliable). Leave the clients as they are.
In other words: on the PDCe, open a command prompt and enter (replacing <> with the time server of your choice; the ,0x8 at the end will tell the time service to run in ntp client mode):

w32tm /config /manualpeerlist:<>,0x8 /update
w32tm /resync

Time servers are here; pick a time server geographically close to you, for example one of these:

A list of the Simple Network Time Protocol (SNTP) time servers that are available on the Internet

The project

Do you have to use vb?  Here is the command prompt syntax:

NET TIME \\domaincontroller /SET /Y

so you could do a:

shell "NET TIME \\domaincontroller  /SET /Y"

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial