Management Object(WMI) is a good method if you use XP or later.
public void SetSystemTime(string host, string username, string password, DateTime dt)
{
ConnectionOptions options = new ConnectionOptions();
options.Username = username;
options.Password = password;
path = new ManagementPath(String.Format("\\\\{0}\\root\\cimv2", host));
scope = new ManagementScope(path, options);
foreach (ManagementObject classInstance in new ManagementClass(scope, new ManagementPath("Win32_OperatingSystem"), null).GetInstances())
{
ManagementBaseObject inParams = classInstance.GetMethodParameters("SetDateTime");
inParams["LocalDateTime"] = ManagementDateTimeConverter.ToDmtfDateTime(dt);
ManagementBaseObject outParams = classInstance.InvokeMethod("SetDateTime", inParams, null);
}
}
Alternatively, you could use PSTools:
http://technet.microsoft.com/en-us/sysinternals/bb897553[
^]
PsExec.exe -u domain/username -p password \\RemoteServerName cmd /C date 07-11-2010
You could use this and create a small .Net Program. Use System.Diagnostic.Process.Start("the above command")
Note: Use full path to PsExec.exe when you use inside Process.Start method
Thanks,
Kuthuparakkal