Set the date, time, and amp time zone on the remote computer using C #


How do you set date, time and the time zone setting of the remote computer using C#? Basically, I want to update the time on selected machines in the network.

Creating time server is not an option as I want to update the time only on the user selected computers. All the remote computers are running windows XP or higher operating system.

Executing a remote process through WMI and .NET are extensively documented online. You can execute the date, time and tzutil DOS utilities to accomplish what you need. However, I think PsExec is the way to go.

You only need to download the 1.6 MB utility once on your computer and use it to execute all kinds of remote processes on your XP machines. Here's how you can change the timezone to Central Time using PsExec:

psexec \\RemPC01 TZUTIL /s "Central Standard Time"

You can wrap this in a bit of .NET code and it should do what you want:

string remoteMachine = "RemPC01";
string appName = "psexec.exe";
string args = string.Format("\\\\{0} TZUTIL /s \"Central Standard Time\"", remoteMachine);
Process.Start(appName, args);