Group:  English: Windows Server ยป microsoft.public.windows.server.scripting
Thread: 2000 uptime

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

2000 uptime
"Drew Govnyak" <drew[ at ]myemail.com> 06.07.2007 18:33:39
Script shown below returns up time value on a Win 2000 system in minutes.
Can someone help me with the code to show days instead of minutes?

Thank you very much

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")

For Each objOS in colOperatingSystems
dtmBootup = objOS.LastBootUpTime
dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
dtmSystemUptime = DateDiff("n", dtmLastBootUpTime, Now)
Wscript.Echo dtmSystemUptime & " minutes"
Next

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



Re: 2000 uptime
"Tim" <tim j williams at gmail dot com> 06.07.2007 18:49:52
usually:

days = minutes/(60*24)

.... probably rounded to some sensible precision.

Tim


"Drew Govnyak" <drew[ at ]myemail.com> wrote in message
news:%23fv31w$vHHA.2040[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
> Script shown below returns up time value on a Win 2000 system in minutes.
> Can someone help me with the code to show days instead of minutes?
>
> Thank you very much
>
> strComputer = "."
>
> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> Set colOperatingSystems = objWMIService.ExecQuery _
> ("Select * from Win32_OperatingSystem")
>
> For Each objOS in colOperatingSystems
> dtmBootup = objOS.LastBootUpTime
> dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
> dtmSystemUptime = DateDiff("n", dtmLastBootUpTime, Now)
> Wscript.Echo dtmSystemUptime & " minutes"
> Next
>
> 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
>
>
>


Re: 2000 uptime
"D.R." <a[ at ]b.c.d> 08.07.2007 08:18:50
Function fs_zeroes( pl_number, pl_length )
Const cs_fac = "%fs_zeroes, "
Dim ls_result
ls_result = String( pl_length, "0" ) & CStr( pl_number )
ls_result = Right( ls_result, pl_length )
fs_zeroes = ls_result
End Function

Function fs_right( ps_text, pl_len )
Const cs_fac = "%fs_right, "
If Len( ps_text ) > pl_len Then
fs_right = ps_text
Else
fs_right = Right( Space( pl_len ) & ps_text, pl_len )
End If
End Function

Function fs_duration( pd_start, pd_end )
Const cs_fac = "%fs_duration, "
Dim ll_diff, ll_dddd, ll_hh, ll_mm, ll_ss, ls_duration
ll_diff = DateDiff( "s", pd_start, pd_end )
ll_ss = ll_diff - ( ( ll_diff \ 60 ) * 60 )
ll_diff = ll_diff \ 60
ll_mm = ll_diff - ( ( ll_diff \ 60 ) * 60 )
ll_diff = ll_diff \ 60
ll_hh = ll_diff - ( ( ll_diff \ 24 ) * 24 )
ll_diff = ll_diff \ 24
ll_dddd = ll_diff
ls_duration = ""
ls_duration = ls_duration & fs_right( ll_dddd, 4 ) & " "
ls_duration = ls_duration & fs_zeroes( ll_hh, 2 ) & ":"
ls_duration = ls_duration & fs_zeroes( ll_mm, 2 ) & ":"
ls_duration = ls_duration & fs_zeroes( ll_ss, 2 )
fs_duration = ls_duration
End Function



"Drew Govnyak" <drew[ at ]myemail.com> wrote in message
news:%23fv31w$vHHA.2040[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
> Script shown below returns up time value on a Win 2000 system in minutes.
> Can someone help me with the code to show days instead of minutes?
>
> Thank you very much
>
> strComputer = "."
>
> Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
> Set colOperatingSystems = objWMIService.ExecQuery _
> ("Select * from Win32_OperatingSystem")
>
> For Each objOS in colOperatingSystems
> dtmBootup = objOS.LastBootUpTime
> dtmLastBootupTime = WMIDateStringToDate(dtmBootup)
> dtmSystemUptime = DateDiff("n", dtmLastBootUpTime, Now)
> Wscript.Echo dtmSystemUptime & " minutes"
> Next
>
> 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
>
>
>


Re: 2000 uptime
Dominic Johnson <johnsondominic[ at ]hotmail.com> 12.07.2007 10:08:34
On 6 Jul, 19:33, "Drew Govnyak" <d...[ at ]myemail.com> wrote:
[Quoted Text]
> Can someone help me with the code to show days instead of minutes?


You are using the DateDiff interval "n" - this produces a date
difference expressed in minutes.

Use the DateDiff interval "d" which produces a date diffrrence
expressed in days.

Dominic

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net