1: ' Configures the PDC Emulator in the root of a forest to be an authoritative time server
2: ' and sync time from several NTP time servers on the Internet
3: ' Info gathered from KB816042 How to configure an authoritative time server in
4: ' Windows Server 2003 (http://support.microsoft.com/kb/816042)
5: '
6: ' On a PDC Emulator the settings changed from the default settings are:
7: ' Type (From NT5DS to NTP)
8: ' AnnounceFlags (From 10 to 5)
9: ' NTPServer (From time.windows.com,0x1 to contents of strTimeServers)
10: ' SpecialPollInterval (From 3600 to 900)
11: ' MaxPosPhaseCorrection (From 4294967295 to 1800)
12: ' MaxNegPhaseCorrection (From 4294967295 to 1800)
13: '
14: ' A useful command line command is:
15: ' w32tm /config /manualpeerlist:"time-a.nist.gov time-b.nist.gov time.nist.gov time-nw.nist.gov" /syncfromflags:manual /reliable:yes /update
16: ' This command sets AnnounceFlags to 5, NTPServer to the server list and Type to NTP
17: ' Command found here:
18: ' http://technet2.microsoft.com/windowsserver/en/library/ce8890cf-ef46-4931-8e4a-2fc5b4ddb0471033.mspx?mfr=true
19: '
20: ' A list of the NIST time server can be found here:
21: ' http://tf.nist.gov/service/time-servers.html
22: '
23: ' Microsoft's list of (S)NTP servers is here:
24: ' http://support.microsoft.com/kb/262680/en-us
25:
26: const HKEY_CURRENT_USER = &H80000001
27: const HKEY_LOCAL_MACHINE = &H80000002
28: strKeyPath = "SYSTEMCurrentControlSetServicesW32Time"
29:
30: strTimeServers = "time-a.nist.gov,0x1 time-b.nist.gov,0x1 time-a.timefreq.bldrdoc.gov,0x1 time-b.timefreq.bldrdoc.gov,0x1 time-c.timefreq.bldrdoc.gov,0x1 utcnist.colorado.edu,0x1 time.nist.gov,0x1 time-nw.nist.gov,0x1 nist1.dc.certifiedtime.com,0x1 nist1.datum.com,0x1 nist1.nyc.certifiedtime.com,0x1 nist1.sjc.certifiedtime.com,0x1"
31: strComputer = "."
32: Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "rootdefault:StdRegProv")
33:
34: 'Change the server type to NTP (KB Step 1)
35: objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "Parameters","Type","NTP"
36: 'Set AnnounceFlags to 5 (KB Step 2)
37: objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath & "Config","AnnounceFlags",5
38: 'Enable NTPServer (KB Step 3)
39: objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath & "TimeProvidersNtpServer","Enabled",1
40: 'Specify the time sources (KB Step 4)
41: objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath & "Parameters","NtpServer",strTimeServers
42: 'Select the poll interval (KB Step 5)
43: objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath & "TimeProvidersNtpClient","SpecialPollInterval",900
44: 'Configure the time correction settings (KB Step 6)
45: objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath & "Config","MaxPosPhaseCorrection",1800
46: objReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath & "Config","MaxNegPhaseCorrection",1800
47:
48: Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer & "rootcimv2")
49: Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='W32Time'")
50: For Each objService in colListOfServices
51: retVal = objService.StopService()
52: If retVal = 0 Then
53: 'WScript.Echo "Service stopped"
54: Else
55: WScript.Echo "Service stop failed (" & retVal & ")"
56: End If
57: WScript.Sleep 5000
58: retVal = objService.StartService()
59: If retVal = 0 Then
60: 'WScript.Echo "Service started"
61: Else
62: WScript.Echo "Service start failed (" & retVal & ")"
63: End If
64: Next
65:
66: WScript.Echo "Done!"