How to change the time synchronization interval in Windows (VBScript)

Introduction

This VBScript sample shows how to change the Internet Time Synchronization interval.

Scenarios

Windows includes internet time synchronization scheduler to synchronize your clock automatically. But the default synchronization interval for this process is one week. There is no way to change this interval through the user interface. It has to be done using the registry editor. So this script sample can easily help user to do it.

Script

Step 1: You can run this VBScript sample by simply double-clicking.

The step is shown in the following figure.

Then, you can follow the prompts to select.

In this example, we input 1 that means we want to set internet time synchronization in hours.

When the script finishes running, it will spawn a window that displays brief information about the result.

Here are some code snippets for your references.

VB Script
Edit|Remove
Dim objRegistry 
Dim strKeyPath 
Dim strValueName 
Dim strComputer 
  
Const HKEY_LOCAL_MACHINE = &H80000002 
strComputer = "." 
  
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") 
  
'Define a key registry path 
strKeyPath = "SYSTEM\CurrentControlSet\Services\w32Time\TimeProviders\NtpClient" 
objRegistry.CreateKey HKEY_LOCAL_MACHINE, strKeyPath 
strValueName = "SpecialPollInterval" 
  
objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue 
WScript.Echo "Set the Internet Time Syncronization successfully."

Prerequisite

Windows 7 or higher version