0

My server is Windows server 2008 R2. I have some logic need to detect the time from other place, If the system time not match. I need to change it . But I don't find the way.

I try also add a console project, every time open it to change the time, But It will easy to delete and I heard Windows server can't start process after Vista.

So Is there a good way to change system time in windows service?

Community
  • 1
  • 1
qakmak
  • 1,287
  • 9
  • 31
  • 62
  • Below link may have answer how to change system time using setsystemtime https://msdn.microsoft.com/en-us/library/ms172517(v=vs.90).aspx http://stackoverflow.com/questions/650849/change-system-date-programatically – Dreamweaver May 14 '15 at 06:28
  • But make sure your service account has privileges to change date time in Windows (Local Service, Local System should be ok). – Vojtěch Dohnal May 14 '15 at 06:31
  • There's already a protocol designed to synchronize time across machines (NTP) and windows implements a client for it. Why are you re-inventing the wheel? – Damien_The_Unbeliever May 14 '15 at 07:16
  • @Damien_The_Unbeliever Because it can be disable manually. – qakmak May 14 '15 at 07:36

0 Answers0