如何从InTouch Scriptng中的本地网络中的远程PC或Archestra IDE中的QuickScript.NET接收系统时间?
答案 0 :(得分:0)
您应该可以在此处获得任何答案:Get remote PC's date time?
QuickScript.NET示例
首先,从System.Management
或您拥有的任何位置导入C:\Windows\Microsoft.NET\Framework\v4.0.30319
DLL作为脚本函数库。
之后,使用此脚本并调整您的需求:
(我在ArchestrA图形中有2个文本字段,datestring
和timestring
是绑定到显示对象的标记。
脚本条件:refresh
== True:
dim pcname as System.String;
dim wmipath as System.String;
dim scope as System.Management.ManagementScope;
dim query as System.Management.ObjectQuery;
dim search as System.Management.ManagementObjectSearcher;
try
pcname = "192.168.10.190";
wmipath = System.String.Format("\\{0}\root\CIMV2", pcname);
scope = new System.Management.ManagementScope(wmipath);
query = new System.Management.ObjectQuery("SELECT * FROM Win32_LocalTime");
scope.Connect();
search = new System.Management.ManagementObjectSearcher(scope, query);
dim queryObj as System.Management.ManagementObject;
for each queryObj in search.Get()
datestring = System.String.Format("{0}-{1}-{2}", queryObj("Year"), queryObj("Month"), queryObj("Day"));
timestring = System.String.Format("{0}:{1}:{2}", queryObj("Hour"), queryObj("Minute"), queryObj("Second"));
LogMessage(datestring + " " + timestring);
next;
catch
LogError(error);
endtry;
refresh = false;