Skip to content

Instantly share code, notes, and snippets.

@PureOcean
Last active January 18, 2026 08:48
Show Gist options
  • Select an option

  • Save PureOcean/57fd7a5dcd10db6494144dddd33020c4 to your computer and use it in GitHub Desktop.

Select an option

Save PureOcean/57fd7a5dcd10db6494144dddd33020c4 to your computer and use it in GitHub Desktop.
Set Automatically Date on Windows Command Line
"%windir%\system32\SystemSettingsAdminFlows.exe" SetInternetTime 1
:: This is command line equivalent of 'Set time automatically' in Windows Settings -> Time & Language -> Data & Time
:: How did I discover it?
:: In Windows Settings (Time & Language -> Date & Time -> ‘Set time automatically’), the system date can be set automatically. I wanted to implement this in the command line or in a BAT file. By turning this setting off and on in Windows Settings, I used Process Monitor (ProcMon) to identify the actual command running in the background.
:: Although the word “Internet” appears in the argument, an Internet connection is not required. I believe it reads and corrects the date from the CMOS/RTC. It uses the W32time service. Even though the service is disabled (net stop W32time /y && sc config W32time start= disabled), this command enables the service (“demand”) and starts it.
:: This command, which I tested in Windows 11 (10.0.26100), is also available in Windows 8, 8.1, 10.
:: In which build of Windows was this command added? When I opened the SystemSettingsAdminFlows.exe file in Windows 8 (Build 6.3.9600) with HxD (Hex Editor) and searched for the term “SetInternetTime” in UTF-16 (Search: CTRL F -> Text encoding: Unicode), I found it.
:: When I looked it up on Google, I realized it was not well known.
:: Ilya Reshetnikov wrote on his site (on January 18, 2024): https://isbyr.com/fix-time-drift-on-utm-windows-vm/
:: It is also documented in the libraries of several antivirus sites(2020-10-09): https://vms.drweb.com/virus/?i=21898960
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment