Dim computer1
Dim Domaincontroller
Dim value1
Dim value2
Dim difference
strComputer = "alice"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_LocalTime")
For Each objItem in colItems
intMonth = objItem.Month
intDay = objItem.Day
intYear = objItem.Year
dtmDate = intMonth & "/" & intDay & "/" & intYear
intHour = objItem.Hour
If intHour < 12 Then
strAMPM = "AM"
Else
intHour = intHour - 12
strAMPM = "PM"
End If
intMinutes = objItem.Minute
If intMinutes < 10 Then
intMinutes = "0" & intMinutes
End If
intSeconds = objItem.Second
If intSeconds < 10 Then
intSeconds = "0" & intSeconds
End If
dtmTime = intHour & ":" & intMinutes & ":" & intSeconds & " " & strAMPM
firstDate = dtmDate & " " & dtmTime
'Wscript.Echo firstDate
Next
strComputer1 = "dc1"
Set objWMIService = GetObject("winmgmts:\\" & strComputer1 & "\root\cimv2")
Set colItems1 = objWMIService.ExecQuery("Select * From Win32_LocalTime")
For Each objItem in colItems1
intMonth = objItem.Month
intDay = objItem.Day
intYear = objItem.Year
dtmDate = intMonth & "/" & intDay & "/" & intYear
intHour = objItem.Hour
If intHour < 12 Then
strAMPM = "AM"
Else
intHour = intHour - 12
strAMPM = "PM"
End If
intMinutes = objItem.Minute
If intMinutes < 10 Then
intMinutes = "0" & intMinutes
End If
intSeconds = objItem.Second
If intSeconds < 10 Then
intSeconds = "0" & intSeconds
End If
dtmTime = intHour & ":" & intMinutes & ":" & intSeconds & " " & strAMPM
nextDate = dtmDate & " " & dtmTime
' Wscript.Echo nextDate
next
myDif = DateDiff("s",firstDate,nextDate)
'Wscript.Echo myDif
ourMessage = "hi"
If myDif > 900 Then
ourMessage = "0"
Else
ourMessage = "1"
End If
If myDif < -900 Then
ourMessage = "0"
Else
ourMessage = "1"
End If
Wscript.Echo ourMessage
'///////////////////////////////////////////
' Convert WMI Time Function
'///////////////////////////////////////////
On Error Resume Next
Function ConvWMITime(wmiTime)
yr = left(wmiTime,4)
mo = mid(wmiTime,5,2)
dy = mid(wmiTime,7,2)
tm = mid(wmiTime,9,6)
ConvWMITime = mo&"/"&dy&"/"&yr & " " & FormatDateTime(left(tm,2) & _
":" & Mid(tm,3,2) & ":" & Right(tm,2),3)
End Function
No comments:
Post a Comment