uptime script

7:00 PM

create a TXT file by Name Servers with the list of Servers you wanted to check. It will automatically created a Output

SCRIPT STARTS FROM BELOW

'==========================================================================
Option Explicit
On Error Resume Next

Dim strComputer, objWMIService, colOperatingSystems, objOS, intSystemUptime, Question
Question = ""
Do Until Question = vbNo
strComputer = InputBox("Please enter servername")

If strComputer <> "" Then
GetTime

Else
Question = MsgBox ("Please try again and enter a valid server name" & vbCrLf & "Try again?", vbYesNo)
If Question = vbNo Then
WScript.Quit


End If
End If
Loop

'===========================================================================
' Sub Procedures
'===========================================================================
Sub GetTime

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * From Win32_PerfFormattedData_PerfOS_System")

For Each objOS in colOperatingSystems
intSystemUptime = SplitSec(objOS.SystemUpTime)
'intSystemUptime = Int(objOS.SystemUpTime / 60)
MsgBox "The server has been up for " & intSystemUptime
Question = vbNo
Next

End Sub

Function SplitSec(pNumSec)
Dim d, h, m, s
Dim h1, m1

d = int(pNumSec/86400)
h1 = pNumSec - (d * 86400)
h = int(h1/3600)
m1 = h1 - (h * 3600)
m = int(m1/60)
s = m1 - (m * 60)

SplitSec = cStr(d) & " Days, " & cStr(h) & " Hours, " & cStr(m) & " Minutes, " & cStr(s) & " Seconds."
End Function

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results