Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script for system uptime

Status
Not open for further replies.

keithvp

Instructor
Aug 10, 2000
19
US
Does anyone have a script that checks the system uptime of a Windows 2000 server? The script I have is only for XP and Windows.net.
 
Try something like this
------------------
'lastboot.vbs Date of last boot of machine requires Admin Priv to run
dim strMonth
ComputerName = InputBox("Enter the name of the computer you wish to query")

winmgmt1 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName & ""

winmgmt2 = "winmgmts:{impersonationLevel=impersonate}!//"& ComputerName & ""

Set SPSet = GetObject( winmgmt1 ).InstancesOf ("Win32_OperatingSystem")

Set QFESet = GetObject( winmgmt2 ).InstancesOf ("Win32_QuickFixEngineering")


'WScript.Echo "=========================================="
WScript.Echo "Computer Operating System Properties for " & "" & ComputerName & ""
'WScript.Echo "=========================================="

For each SP in SPSet
'WScript.Echo "Operating System: " & SP.Name
'WScript.Echo "Build Number: " & SP.BuildNumber
'WScript.Echo "Build Type: " & SP.BuildType
'WScript.Echo "Service Pack: " & SP.CSDVersion
'WScript.Echo "Serial Number: " & SP.SerialNumber
'WScript.Echo "Registered User: " & SP.RegisteredUser
select case mid(SP.LastBootUpTime,5,2)
case "01"
strMonth = "January"
case "02"
strMonth = "February"
case "03"
strMonth = "March"
case "04"
strMonth = "April"
case "05"
strMonth = "May"
case "06"
strMonth = "June"
case "07"
strMonth = "July"
case "08"
strMonth = "August"
case "09"
strMonth = "September"
case "10"
strMonth = "October"
case "11"
strMonth = "November"
case else
strMonth = "December or later"
end select
msgbox "Lasted Booted on: " & mid(SP.LastBootUpTime,7,2) & " " & strMonth & " " & mid(SP.LastBootUpTime,1,4) & " at " & mid(SP.LastBootUpTime,9,2) & ":" & mid(SP.LastBootUpTime,11,2)
'WScript.Echo "Lasted Booted on: " & mid(SP.LastBootUpTime,7,2) & " " & strMonth & " " & mid(SP.LastBootUpTime,1,4) & " at " & mid(SP.LastBootUpTime,9,2) & ":" & mid(SP.LastBootUpTime,11,2)
'WScript.echo SP.LastBootUpTime
'WScript.Echo "Windows Directory: " & SP.WindowsDirectory
'WSCript.Echo "System Directory: " & SP.SystemDirectory
next


---------------------

Gives you date - still debugging time
 
Function getvbdate(wd)
getvbdate = DateSerial(left(wd,4),mid(wd,5,2),mud(wd,7,2)) + TimeSerial(mid(wd,9,2),mid(wd,11,2),mid(wd,13,2))

End Function

should convert the ugly wmi date and times for you
 
I tried the code above and it works on my XP PC but when I run it on a 2000 server I get "December or later" for the field value. What am I missing? Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top