Return how long the computer has been running.
Return format is dd:hh:mm:ss (from Seconds2Time function).
Tested on different computers, each one accurately displays the uptime. Originally by Rob R
Uses FileSystemObject to read the DateLastModified attribute from the pagefile.sys.
Function ServerUptime()
Dim UptimeInSeconds
Set fso = CreateObject("Scripting.FileSystemObject")
Set PageFile = fso.GetFile ("C:\pagefile.sys") ' get the page
UptimeInSeconds = DateDiff("S", PageFile.DateLastModified, Now()) ' Finds how many seconds between now and the pagefile mod date
ServerUptime = Seconds2Time(UptimeInSeconds) ' Calls a function to format the seconds
Set PageFile = Nothing
Set fso = Nothing
End Function
Dim UptimeInSeconds
Set fso = CreateObject("Scripting.FileSystemObject")
Set PageFile = fso.GetFile ("C:\pagefile.sys") ' get the page
UptimeInSeconds = DateDiff("S", PageFile.DateLastModified, Now()) ' Finds how many seconds between now and the pagefile mod date
ServerUptime = Seconds2Time(UptimeInSeconds) ' Calls a function to format the seconds
Set PageFile = Nothing
Set fso = Nothing
End Function
? ServerUptime
0:22:49:37
0:22:49:37
Views 4,703
Downloads 1,391
CodeID
DB ID