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

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

Creating a time server is not an option, since I want to update the time only on user-selected computers. All remote computers are running Windows XP or higher.

+4
source share
2 answers

Running a remote process through WMI and .NET is widely documented on the Internet. You can run the date , time and tzutil DOS tzutil to accomplish what you need. However, I think PsExec is the way to go.

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

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

You can wrap this in some .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); 
+3
source

I would recommend using PsExec for this. Perhaps use it in conjunction with your application. This gives you console access to remote computers, and the console command you are looking for is the "time" to change the time.

+2
source

Source: https://habr.com/ru/post/1386984/


All Articles