Announcement

Collapse
No announcement yet.

System uptime

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • drule
    replied
    I hacked this up by reading Logs/Startup.hsd. Would be nice if there were an official function though.
    Code:
        Private Function SystemStartTime() As DateTime
            Dim StartupLog As System.IO.StreamReader = My.Computer.FileSystem.OpenTextFileReader("Logs/Startup.log")
            Dim FirstLogEntry As String = StartupLog.ReadLine
            StartupLog.Close()
            Dim LogElements As String() = FirstLogEntry.Split(" ")
            If LogElements.Count > 2 Then
                Return Convert.ToDateTime(LogElements(0) & " " & LogElements(1) & " " & LogElements(2))
            End If
            Return Convert.ToDateTime("1/1/2020 00:00:00")
        End Function
    
        Public Function SystemUpTime() As String
            Dim TS As TimeSpan = SystemUpTimeTS()
            Return TS.Days.ToString & " Days " & TS.Hours.ToString & ":" & TS.Minutes.ToString.PadLeft(2, "0") & ":" & TS.Seconds.ToString.PadLeft(2, "0")
        End Function
    
        Public Function SystemUpTimeTS() As TimeSpan
            Return Now.Subtract(SystemStartTime)
        End Function

    Leave a comment:


  • drule
    started a topic System uptime

    System uptime

    Is there an equivalent to HS3's hs.SystemUpTime() function?
Working...
X