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: Visual basic script doesn't work in gadget

12 Sep 2012   #1

Windows 8 Pro (32-bit)
 
 
Visual basic script doesn't work in gadget

Yes I know we shouldn't be using gadgets, but I simply don't care.

I've been using Computer Status (Computer Status Gadget v3.5 by ~drakesteele on deviantART) for the longest time, and all versions have this annoying bug where the uptime part doesn't work, where immediately after booting up it says -68 (negative) days or so and counts down from that day. It seems to work fine on other people's computers, but it doesn't work on my desktop or laptop. I've tried running sidebar in 32 bit mode and installing the latest version of .NET, and nothing seems to help. I'm assuming that I don't have something installed that the gadget relies on.

This is the code itself that I'm assuming the problem is in:
Code:
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 )
			intSecsTotal    = ( intSecsTotal - ( intMinutes * 60 ))
			intSeconds      = Fix( intSecsTotal )
		 
			//uptimeTxt.innerText = intDays & " days " & intHours & " hours " & intMinutes & " minutes"
			uptimeTxt.innerText = intDays & "D " & intHours & "H " & intMinutes & "M " & intSeconds & "S "
			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 SpecsSystem Spec
.

Reply

 Visual basic script doesn't work in gadget





Thread Tools




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 10:31 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33