I'm generating an "Up-Time" Win7 Gadget and trying to reproduce the .vbs code found in similar Gadgets.
I'm a .js coder.
Relevant JS:
vbStr=GetUpTime();
Relevant VBS:
Function GetUpTime
Set loc=CreateObject("WbemScripting.SWbemLocator")
Set svc=loc.ConnectServer(MachineName, "root\cimv2")
Set oss=svc.ExecQuery("SELECT * FROM Win32_OperatingSystem")
For Each os in oss
tim=os.LastBootUpTime
Next
GetUpTime=tim
End Function
Essentially this .vbs does the trick, as currently there is only 1 os
running. I would like to expand on this by learning:
1) What is the relevance of MachineName
?
If I return MachineName
instead of tim
, I get an undefined
value.
2) How to extract individual os
's without the For Each
loop, equivelant to the .js:
os=oss[n];
3) How to return an array of tim
's relative to each os
.
The .vbs code loops through the available os
's and gets their respective up-times, but the developer only planned for 1 os
and as such there was no code to return an array of tim
's. After researching .vbs arrays I've found how to create a 'set-length' array, but this is not relevant!