asked on
'------ Constants ------>
Const ForReading = 1
Const ForAppending = 8
Const ForWriting = 2
'------ Variables ------>
Dim strComputer
Dim objFileSrc 'source file location
Dim objFSOSrc 'source file object
Dim strFileSrc 'source file location
Dim objFile1 'output file object
Dim strFile1 'output file location
Dim objFSO 'output file location
Dim arr1 'Server Arry from File
Dim minArr() 'Minutes array
Dim secArr() 'Seconds Array
Dim strDiff 'Location for time seperation
'----- Initializations ------
On Error Resume Next
strFileSrc = "all.ini" 'File to pull server list from
set objFSOSrc = createobject("Scripting.filesystemobject")
set objFileSrc = objFSOSrc.OpenTextFile(strFileSrc, forReading, false)
arr1 = Split(objFileSrc.ReadAll, VbCrLf) 'Load server name array
cnt = ubound(arr1) 'count total number or fields in array
For i = 0 to cnt 'loops to populate arrays with minute and second data
strComputer = arr1(i) 'load Server Name variable.
'msgbox arr1(i)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LocalTime")
For Each objItem in colItems
redim Preserve minArr(i) 'prep array location
minArr(i) = objItem.Minute 'load array location
redim Preserve secArr(i) ' prep array location
secArr(i) = objItem.Second 'load array location
Next
Next
for i = 1 to cnt 'time difference and reporting
strDiff = minArr(0) - minArr(i) 'find difference
'msgbox strDiff & " Is the difference"
if strDiff <> zero then "if there's a time difference
strFile1 = arr1(i) & "_Err.txt" 'file name creation
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile1 = objFSO.CreateTextFile(strFile1, ForWriting, true)
objFile1.writeline "Minutes on " & arr1(0) & " is " & minArr(0) & "." & VbCrLf & _
"Minutes on " & arr1(i) & " is " & minArr(i) & "." & VbCrLf & _
"Total difference is " & strDiff & "." 'writing file
objFile1.Close 'Closing file
else
strFile1 = arr1(i) & "_Good.txt" 'file name creation
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile1 = objFSO.CreateTextFile(strFile1, ForWriting, true)
objFile1.writeline "Minutes on " & arr1(0) & " is " & minArr(0) & "." & VbCrLf & _
"Minutes on " & arr1(i) & " is " & minArr(i) & "." & VbCrLf & _
"Total difference is " & strDiff & "." 'writing file
objFile1.Close 'closing file.
end if
Next
msgbox "DONE!"
ASKER
ASKER
VBScript (Visual Basic Scripting Edition) is an interpreted scripting language developed by Microsoft that is modeled on Visual Basic, but with some important differences. VBScript is commonly used for automating administrative and other tasks in Windows operating systems (by means of the Windows Script Host) and for server-side scripting in ASP web applications. It is also used for client-side scripting in Internet Explorer, specifically in intranet web applications.
TRUSTED BY
Hate to be the bearer of bad news but this class (Win32_LocalTime) is not suppported in Win2000
See here
http://msdn.microsoft.com/en-us/library/aa394171(VS.85).aspx
Regards
Krystian