bsharath
asked on
How can i qury the machines uptime in a ie window.
Hi,
I want a script to get me the uptime from all machines in the domain in a ie,hta or excel window.Is there a way to do this..
Regards
Sharath
I want a script to get me the uptime from all machines in the domain in a ie,hta or excel window.Is there a way to do this..
Regards
Sharath
ASKER
I just get this box..
-------------------------- -
Windows Script Host
-------------------------- -
189
-------------------------- -
OK
-------------------------- -
--------------------------
Windows Script Host
--------------------------
189
--------------------------
OK
--------------------------
It was a working sample to show you some code that you could use. It wasn't the actual script to use. It pops up the number of hours the system has been up. You could change that to minutes, seconds, days, weeks, months, and even years.
ASKER
Ok How can i change this to get the details of all machines to a file and to change it to no of days wise...
Sorry i have very limited knowledge of scripting...
Sorry i have very limited knowledge of scripting...
The easiest is to do a For loop that counts up or down 0-255. I don't know your network so I cannot really help you with that. As for changing to days you just need to change line 9. It currently has an "h" and to switch to days you need to change it to "d".
Here is a list of the values it takes in that position:
yyyy - Year
q - Quarter
m - Month
y - Day of year
d - Day
w - Weekday
ww - Week of year
h - Hour
n - Minute
s - Second
Here is a list of the values it takes in that position:
yyyy - Year
q - Quarter
m - Month
y - Day of year
d - Day
w - Weekday
ww - Week of year
h - Hour
n - Minute
s - Second
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Rob this works fine but i get just 19 machines when run
Can we even mention the machine names in colum A?
Can we even mention the machine names in colum A?
Oh whoops! Yeah, I left in an Exit For for testing....remove this line
If intRow = 20 Then Exit For
and it will get all of them.....
Rob.
If intRow = 20 Then Exit For
and it will get all of them.....
Rob.
ASKER
Ok...
After 38 machine i get a run time error when debug
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))
After 38 machine i get a run time error when debug
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))
Hmmm, not sure why....that may be a problem with the date on a few machines....we'll check that later....for now, change this:
Function WMIDateStringToDate(dtmBoo tup)
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
to this:
Function WMIDateStringToDate(dtmBoo tup)
If Len(dtmBootUp) > 13 Then
strTheDate = Mid(dtmBootup, 5, 2) & "/" & _
Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
& " " & Mid(dtmBootup, 9, 2) & ":" & _
Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup, _
13, 2)
Else
strTheDate = "01/01/1901 00:00:00"
End If
If IsDate(strTheDate) = False Then strTheDate = "01/01/1901 00:00:00"
WMIDateStringToDate = CDate(strTheDate)
End Function
And see how you go. For those computers that would have had an error, you'll get an uptime of somewhere near 36500 days.....incorrect obviously, but we'll check that later once we know which machines are like that.
Regards.
Rob.
Function WMIDateStringToDate(dtmBoo
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
to this:
Function WMIDateStringToDate(dtmBoo
If Len(dtmBootUp) > 13 Then
strTheDate = Mid(dtmBootup, 5, 2) & "/" & _
Mid(dtmBootup, 7, 2) & "/" & Left(dtmBootup, 4) _
& " " & Mid(dtmBootup, 9, 2) & ":" & _
Mid(dtmBootup, 11, 2) & ":" & Mid(dtmBootup, _
13, 2)
Else
strTheDate = "01/01/1901 00:00:00"
End If
If IsDate(strTheDate) = False Then strTheDate = "01/01/1901 00:00:00"
WMIDateStringToDate = CDate(strTheDate)
End Function
And see how you go. For those computers that would have had an error, you'll get an uptime of somewhere near 36500 days.....incorrect obviously, but we'll check that later once we know which machines are like that.
Regards.
Rob.
ASKER
Rob sorry for the delay in responding.My laptop has an motherboard issue and i have given it for service.I am at my relatives place to Browse now.
For most of the machines i get as "OFF" does this mean that the macro queries each machine directly to get the info.?.If yes then the macro works fine.
Except this message and some data as 36500
"Microsoft office excel is waiting for another application to complete an OLE action.
For most of the machines i get as "OFF" does this mean that the macro queries each machine directly to get the info.?.If yes then the macro works fine.
Except this message and some data as 36500
"Microsoft office excel is waiting for another application to complete an OLE action.
Yes, if it reports OFF that means it could not ping the machine, and that means it will not be able to get the LastBootUpTime. The machine must be on so it can read the last boot up time from the OS.
Regards,
Rob.
Regards,
Rob.
ASKER
Thanks Rob....
For i=0 to 256
strComputer = 192.168.1.i
Open in new window