windowsrustntp

Programmatically disable NTP?


I'm writing a desktop app that changes the system time. In order for this to work I need to disable NTP when the app starts, then enable it again when the app stops.

On linux I can do

        Command::new("timedatectl")
            .args(["set-ntp","0"])

Is there something similar for windows, whether launching an external process or calling a system library?


Solution

  • w32time is the Windows time service.

    net.exe stop w32time
    
    net.exe start w32time