不确定这是否有帮助,但也许通过微软的 UPTIME.exe 有很好的信息。它是一个跟踪正常运行时间、启动、蓝屏等的工具。
这是一个 vbscript,它可能有一些线索来获取 VB.NET 的此信息
我不是在这里找到的作者:
https ://community.spiceworks.com/scripts/show/57-uptime-vbs
' ========================================================
' Script: UpTime.vbs
' Description: Create spreadsheet of uptime stats for all servers
' Note: Change the variables below as required.
' This program requires a copy of Microsoft's UPTIME.EXE tool available from http://support.microsoft.com/kb/232243
' Author: Alan Kobb
' Herley-CTI
' Originally created: 8/26/09
' Copyright 2009, Herley-CTI. ALL RIGHTS RESERVED.
' ========================================================
Set objShell = CreateObject("WScript.Shell")
Set dServers = CreateObject("Scripting.Dictionary")
Dim objExcel, objWorkbook, nPos, strXLFile, objWorksheet, sUpTime
' **********************************************************************************************************
' Variables to set values for
' Add an array element with the name of each server you want to track. Set the DIM to the number of servers.
Dim aServers(2)
aServers(0) = "Server1"
aServers(1) = "Server2"
' The path and name of the Excel file created.
strXLFile = "C:\UpTimes.xls"
' How many days to track for each server.
nDays = "365"
' Path and filename of Uptime.exe (Required. Download from Microsoft at http://support.microsoft.com/kb/232243)
sUpTime = "C:\tools\uptime.exe"
' **********************************************************************************************************
'REGION Open Excel File
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)
'ENDREGION
objWorksheet.Cells(2,1) = "Server"
objWorksheet.cells(1,2) = "% Time"
objWorksheet.cells(2,2) = "Avail"
objWorksheet.Cells(1,3) = "#"
objWorksheet.Cells(2,3) = "Reboot"
objWorksheet.Cells(1,4) = "Current"
objWorksheet.Cells(2,4) = "Uptime"
objWorksheet.Cells(3,4) = "(days)"
objWorksheet.Cells(2,5) = "MTBR"
objWorksheet.Cells(3,5) = "(days)"
objWorksheet.Cells(1,6) = "#"
objWorksheet.Cells(2,6) = "Bluescreens"
objWorksheet.Cells(1,7) = "Abnormal"
objWorksheet.Cells(2,7) = "Shutdowns"
objWorksheet.Cells(2,8) = "Reboots"
objWorksheet.Cells(2,9) = "Shutdowns"
objWorksheet.Cells(2,10) = "Notes"
nRow = 5
For i = 0 To UBound(aServers)
If Len(aServers(i)) > 1 Then
strServer = "\\" & aServers(i)
strCmd = sUpTime & " /p:" & nDays & " " & strserver
WScript.Echo strCmd
Set objExec = objShell.Exec(strCmd)
Do While objExec.Status = 0
WScript.Sleep 2000
Loop
nAvailablePercent = 0
nTotalReboots = 0
nCurrentDays = 0
nMTBR = 0
bTooLittleData = False
bInconsistant = False
nBlues = 0
nAbnormals = 0
nBoots = 0
nShuts = 0
Do While Not(objExec.StdOut.AtEndOfStream)
strLine = objExec.StdOut.ReadLine
'WScript.Echo strLine
If InStr(strLine,"Availability") >= 1 Then nAvailablePercent = field(strLine,":",2)
If InStr(strLine,"Total Reboots") >= 1 Then nTotalReboots = field(strLine,":",2)
If InStr(strLine,"Current System") >= 1 Then nCurrentDays = field(field(field(strLine,":",2),",",1),"d",1)
If InStr(strLine,"Mean") >= 1 Then nMTBR = field(field(strLine,":",2),"d",1)
If InStr(strLine,"earliest") >= 1 Then bTooLittleData = True
If InStr(strLine,"Bluescreen ") >= 1 Then nBlues = nBlues + 1
If InStr(strLine,"Abnormal") >= 1 Then nAbnormals = nAbnormals + 1
If InStr(strLine,"Boot") >= 1 Then nBoots = nBoots + 1
If InStr(strLine," Shutdown") >= 1 Then nShuts = nShuts + 1
Loop
objWorksheet.Cells(nRow,1) = Mid(strServer,3)
objWorksheet.cells(nRow,2) = nAvailablePercent
objWorksheet.Cells(nRow,3) = nTotalReboots
objWorksheet.Cells(nRow,4) = nCurrentDays
objWorksheet.Cells(nRow,5) = nMTBR
objWorksheet.Cells(nRow,6) = nBlues
objWorksheet.Cells(nRow,7) = nAbnormals
objWorksheet.Cells(nRow,8) = nTotalReboots
objWorksheet.Cells(nRow,9) = nShuts
If bTooLittleData Then objWorksheet.Cells(nRow,10) = "Insufficient Data"
nRow = nRow + 1
End If
Next
' Save
objExcel.Visible = True
'objExcel.ActiveWorkbook.SaveAs strXLFile
Function Field(Str,Delim,Pos)
Dim aString
aString = Split(Str,Delim)
Field = aString(Pos-1)
End Function
我还想知道查询 Windows Management Instrumentation 是否有帮助。
我希望这里能有所帮助。祝你好运。