Imran Shams Imran Shams - 7 months ago 66
ASP.NET (C#) Question

Set windows clock in c#

I need to set windows clock in my website (Written in C#)

I found a solution in stackoverflow at:

How do I set the Windows system clock to the correct local time using C#?

But when I use this I give exception:

A required privilege is not held by the client

My Application poll Identity is: LocalSystem


it is not a matter of "I need exact C# function for my problem", this is misguided. This is a security issue. Meddling with the clock is bad. Anyhow, to solve this you may try running the application pool under a user account that is member of the Administrators group and disable UAC.

You wont be able to change the clock on remote clients.

... also don't run an antivirus!

Oh, and disable clock synchronization of your system settings.