|06 Jan 2012||#1|
| || |
Anybody know VB Scripting? Trying to fix an obsolete Gadget.
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() Next 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
|My System Specs|
|07 Jan 2012||#3|
| || |
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
|My System Specs|
|Similar help and support threads for2: Anybody know VB Scripting? Trying to fix an obsolete Gadget.|
|databases obsolete?||System Security|
|How to clean up drop-down menus of obsolete printers||Hardware & Devices|
|Obsolete folders||Installation & Setup|
|How to copy an obsolete program from an old computer?||Software|
|How to Make New Stuff From Your Piles of Obsolete Tech||Chillout Room|
|Removal of unwanted/obsolete add on,help please||Browsers & Mail|
|All your AV software is now Obsolete !!!||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 09:27 PM.