How can I recieve system time from remote PC in local network within InTouch Scriptng or QuickScript.NET in Archestra IDE?
Asked
Active
Viewed 2,594 times
1 Answers
1
You should be able to achieve any of the answers here : Get remote PC's date time?
QuickScript.NET Example
First, Import the System.Management
DLL from C:\Windows\Microsoft.NET\Framework\v4.0.30319
or wherever you have it located as a Script Function Library.
After that, use this script and tweak to your needs:
(I had this in an ArchestrA graphic with 2 text fields, datestring
and timestring
were tags tied to the display objects.
Script Condition: While 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;

Grambot
- 4,370
- 5
- 28
- 43
-
Thanks! Actually my .net version is 3.5 so "try catch" is not supported. But, anyway, I'll try to use your advice without "try catch" – Mike K Jun 01 '18 at 04:42
-
Yeah that's rough without the try-catch but as long as you can do something to handle cases where it fails. I had received a permission issue running the code once on my VM but I think they had a solution in the linked answers to that situation. – Grambot Jun 01 '18 at 17:14