Win10物联网开发的小伙伴们好!
我想编写一个程序来设置带有 Windows 10 IoT 的 Raspberry Pi 3 的时间,这样我的时间戳就会正确。
我正在通过Renci.SshNet生成 SSH 连接,并且类似的代码可以正常工作:
Renci.SshNet.SshClient client = new SshClient(IP, Username, PW);
client.Connect();
client.RunCommand("TZUTIL /s \"W.Europe Standard Time\"");
client.RunCommand("shutdown /r /t 0");
但我不可能通过 Set-Date 命令:
I tried all of the following:
// Manual
client.RunCommand("Set-Date " + ((char)34) + "08.06.2016 14:08:45" + ((char)34));
client.RunCommand("Set-Date \"10/3/2015 2:00PM\"");
// Dynamic
System.DateTime dateTime;
dateTime = System.DateTime.Now.AddHours(2);
String datestr = dateTime.ToString();
client.RunCommand("set-date \"" + datestr + "\"");
有一个指南“如何通过 Shell 命令进行连接”,该命令
Set-Date "08.06.2016 14:31:00"
运行良好,但相同的代码不会在程序中传递任何内容......
我很高兴有任何帮助!