Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Anybody know VB Scripting? Trying to fix an obsolete Gadget.

06 Jan 2012   #1

Windows 8 Pro (32-bit)
Anybody know VB Scripting? Trying to fix an obsolete Gadget.

I've had this gadget That I really love, but it has a couple bugs. The problem is it's no longer supported by the developer. I had managed to fix one (simple formatting error), but the other one I located to being inside a VBScript file. Problem is, I know shit about Visual Basic. I'm pretty sure the problem is in a single line of code , and that would be easier to fix then rewriting the whole thing in JavaScript (especially since I most likely will be upgrading to Windows 8 soon)

The problem is with system uptime. it shows a big negative number, even though I restated earlier today.

Actually it seems to work fine on a computer running 32-bit Windows 7... But how do i fix this?


Function GetUpdateInterval
    UpdateInterval = 1
    System.Gadget.Settings.write "UpdateInterval", UpdateInterval
    GetUpdateInterval = UpdateInterval * 1000
End Function
Sub uptime
    Set objLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objWMIService = objLocator.ConnectServer(MachineName, "root\cimv2")
    Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
        For Each objOS in colOperatingSystems
            dtmBootup = objOS.LastBootUpTime
            dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
            dtmSystemUptimeSecs = DateDiff("s", dtmLastBootUpTime, Now)
            intSecsTotal     = dtmSystemUptimeSecs
            intDays           = Fix( intSecsTotal / 86400 )
            intSecsRemaining = ( intSecsTotal - ( intDays * 86400 ))
            intSecsTotal     = intSecsRemaining
            intHours         = Fix( intSecsTotal / 3600 )
            intSecsTotal    = ( intSecsTotal - ( intHours * 3600 ))
            intMinutes      = Fix( intSecsTotal / 60 )
            uptimeTxt.innerText = intDays & " days " & intHours & " hours " & intMinutes & " minutes"
            setTimeout "uptime()", GetUpdateInterval()
End Sub
Function WMIDateStringToDate(dtmBootup)
    WMIDateStringToDate = CDate(Mid(dtmBootup, 5, 2) & "/" & _
    Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
    & " " & Mid (dtmBootup, 9, 2) & ":" & _
    Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup,13, 2))
End Function
Attached is the Gadget itself.

Attached Files
File Type: zip (322.8 KB, 113 views)
My System SpecsSystem Spec

07 Jan 2012   #2


It looks to me like the issue is not with the code but the internal functions it calls. For some reason they seem to return negative numbers...I have no idea why. Try putting a - in front of each occurrence of Fix. This should turn the negative value into a positive.
My System SpecsSystem Spec
07 Jan 2012   #3

Windows 8 Pro (32-bit)

Actually I figured it's because the function receives a 64bit value, even when Sidebar is in 32bit mode. It's always off by 127 days, so I just changed line 19 to automatically add the difference, so it looks like this:
            intSecsTotal     = dtmSystemUptimeSecs + 10972800
Works fine now. Would need to be changed to work on a 32bit machine, but it's fine for my needs.
My System SpecsSystem Spec


 Anybody know VB Scripting? Trying to fix an obsolete Gadget.

Thread Tools

Similar help and support threads
Thread Forum
Obsolete prefetch files, can they be deleted ?
Can I safely delete a ".pf" file for a non extent exe file. The original EXE program has been uninstalled. I suspect the prefetch might be sabotaging one of my file-types actions. I assume prefetch runs with boot On my trainer wheels with prefetch :o Thank you :)
General Discussion
How to clean up drop-down menus of obsolete printers
I have a home network with two printers attached to the main computer. I got tired of seeing bogus listings in the drop down menu, either leftover from when the printers belonged to a different computer in the network or even listings of printers that were long gone. I opened up Control Panel...
Hardware & Devices
Obsolete folders
I upgraded from XP to 7Pro using the clean install option and used the Easy Transfer facility. I now have a number of folders in Explorer that look like old WP folders eg My Documents, Application Data, Documents and Settings which all appear empty and when I try to open them I get a message to say...
Installation & Setup
How to copy an obsolete program from an old computer?
I have Microsoft Digital Image 2006 on my old laptop, running Windows Vista. I don't remember how I got it on there initially. However, the program is now obsolete and I desperately need it on my new laptop, which is running Windows 7. Is there any way to transfer the program to my new laptop, or...
Removal of unwanted/obsolete add on,help please
I had AVG free anti virus installed on a new computer(Windows 7 home 64)as an interim until i re-activated my Norton subscription.AVG uninstalled,Norton installed but now in IE 8 in manage add-ons AVG Smart Safe(control name is not available) remains no matter what i do(regedit cleanout,changing...
Browsers & Mail
All your AV software is now Obsolete !!!
Hi everybody The latest set of rootkit viruses can now theoretically mess up your BIOS making it virtually impossible to disinfect your computer by traditional means. These don't work "normally" (as in "normal virus code") so current AV software is powerless to detect this stuff. So at...
System Security

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 14:22.

Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App