0

I am able to find the LastTimeSync but not whether the setting is on or not.

 ProcessStartInfo psi = new ProcessStartInfo("w32tm"," /query /status");
            psi.UseShellExecute = false;
            psi.RedirectStandardOutput = true;
            psi.CreateNoWindow = true;
            var proc = System.Diagnostics.Process.Start(psi);
            string s = proc.StandardOutput.ReadToEnd();
            s = s.Substring(s.LastIndexOf("Last"));
            s = s.Remove(s.LastIndexOf("Source"));
Mathieu
  • 6,922
  • 6
  • 27
  • 37
  • This is managed by the "Windows Time" service, so see if its running => https://stackoverflow.com/questions/178147/how-can-i-verify-if-a-windows-service-is-running – Alex K. Jul 17 '18 at 11:28
  • @AlexK. Yes this is managed by WindowsSync Service, Although I am able to get the LastSyncTime of the WindowsTime service but not the state whether the Sync is on or off, I need to fetch the state – piyush sharma Jul 17 '18 at 14:41

0 Answers0