|
-
Nov 1st, 1999, 08:32 PM
#6
New Member
I needed to find the system time on all of our networked PCs after the clocks were turned back this past weekend. I used the following code for this task. The DateCreated method of the FileSystemObject uses the system clock of the target PC when it returns the date.
'Create an output file
open sOutputFile for Output As #1
'Loop through the following code for each machine on the network.
'Create a text file on the target machine
sRemoteFile = sCompName & "\c$\Test.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile(sRemoteFile, True, True)
'Create a text file on the local machine. Use this file to compare time differences
'between the target and local machines. This file should be named differently at each
'loop iteration for this to work correctly.
sLocalFile = "C:\TEMP\~000"
sLocalFile = sLocalFile & Str$(Int(Rnd() * 10000) + 1) & ".TXT"
Set fs1 = CreateObject("Scripting.FileSystemObject")
Set f1 = fs.CreateTextFile(sLocalFile, True, True)
'Get DateCreated for each machine and print results to file
Set f = fs.GetFile(sRemoteFile)
Set f1 = fs1.GetFile(sLocalFile)
s = sCompName & " Target Time: " & f.DateCreated
s1 = vbTab & "Local Time: " & f1.DateCreated
Print #1, s & s1
'Delete files created for determining system time
Kill sRemoteFile
Kill sLocalFile
'End loop
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|