How to get uptime using BGinfo on desktop?

Vinod Kumar Lohar 30 Reputation points
2023-08-01T18:34:56.03+00:00

Hello everyone,

I need assistance in obtaining the system uptime using BGinfo.

I have tried various methods, including PowerShell and VBScript, but unfortunately, I haven't been able to display the uptime information on the BGinfo desktop wallpaper.

Can anyone help me with this issue? Your assistance would be greatly appreciated?

Thanks

Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-08-02T05:54:43.6866667+00:00

    Hi,

    You add a custome field with a VB script like this.

    winmgt = "winmgmts:{impersonationLevel=impersonate}!//"
    Set OS = GetObject(winmgt).InstancesOf("Win32_OperatingSystem")
    For Each ObjItem in OS
    	numUptime  = DateDiff( "s", _
    	             ParseDat( objItem.LastBootUpTime ), _
    	             ParseDat( objItem.LocalDateTime ) )
    	numUptSecs = numUptime Mod 60
    	numUptMins = (numUptime \ 60) Mod 60
    	numUptHour = ( numUptime \ 3600 ) Mod 24
    	numUptDays = ( numUptime \ 3600 )  \  24
    	strUpTime = numUptDays & " Days " & numUptHour & " Hours " & numUptMins & " Minutes " & numUptSecs & " Seconds "
    	echo strUptime
    	
    Next
        
    
    
    Function ParseDat( ByVal strDate )
    	strYear  = Left( strDate, 4 )
    	strMonth = Mid( strDate,  5, 2 )
    	strDay   = Mid( strDate,  7, 2 )
    	strDat   = strYear & "-" & strMonth & "-" & strDay
    	strHour  = Mid( strDate,  9, 2 ) - strTimeShift
    	strMins  = Mid( strDate, 11, 2 )
    	strSecs  = Mid( strDate, 13, 2 )
    	strTime  = strHour & ":" & strMins & ":" & strSecs
    	ParseDat = strDat & " " & strTime
    End Function
    

    I adopted functions from here.

    https://www.robvanderwoude.com/sourcecode.php?src=uptime_vbs#:~:text=%27%20Get%20the%20uptime%20by%20querying%20the%20boot,%3D%20DateDiff%28%22n%22%2C%20_%20ParseDat%20%28objItem.LastBootUpTime%29%2C%20_%20ParseDat%20%28objItem.LocalDateTime%29%29

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    3 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.