Is there a seconds parameter that I can use for time to count seconds
elapsed, for example, I want to use,

if test1 = test2 then
seconds = 1
end if

usage = test1 - test2

wscript.echo usage (I want usage to be able to display how many seconds has
passed)

Re: Seconds Parameter by Robert

Robert
Thu Jul 31 13:08:07 CDT 2003

Second Function
See Also
Day Function | Hour Function | Minute Function | Now Function | Time
Function

Requirements
Version 1

Returns a whole number between 0 and 59, inclusive, representing the second
of the minute.

Second(time)The time argument is any expression that can represent a time.
If time contains Null, Null is returned.

Remarks
The following example uses the Second function to return the current second:

Dim MySec
MySec = Second(Now)
' MySec contains the number representing the current second.
--
Robert Cohen
A legend in his own mind
--

"JC" <Josh@Network-Medics.Com> wrote in message
news:eH5$jx4VDHA.3232@tk2msftngp13.phx.gbl...
> Is there a seconds parameter that I can use for time to count seconds
> elapsed, for example, I want to use,
>
> if test1 = test2 then
> seconds = 1
> end if
>
> usage = test1 - test2
>
> wscript.echo usage (I want usage to be able to display how many seconds
has
> passed)
>
>



Re: Seconds Parameter by Robert

Robert
Thu Jul 31 13:39:01 CDT 2003

you want to use the timer function


Returns the number of seconds that have elapsed since 12:00 AM (midnight).

TimerRemarks
The following example uses the Timer function to determine the time it takes
to iterate a For...Next loop N times:

Function TimeIt(N)
Dim StartTime, EndTime
StartTime = Timer
For I = 1 To N
Next
EndTime = Timer
TimeIt = EndTime - StartTime
End Function
--
Robert Cohen
A legend in his own mind
--

"JC" <Josh@Network-Medics.Com> wrote in message
news:#J97xC5VDHA.2156@TK2MSFTNGP11.phx.gbl...
> One question though, suppose I want to start a second counter at 0 or 1
does
> not matter, and count the number of seconds that elapse until I tell it to
> stop?
> "JC" <Josh@Network-Medics.Com> wrote in message
> news:#BOq6$4VDHA.2316@TK2MSFTNGP09.phx.gbl...
> > Awesome thank you both so much huge help !!!!!!!
> >
> > "Joe Earnest" <joeearnest@qwest.net> wrote in message
> > news:uwCAs44VDHA.1600@TK2MSFTNGP09.phx.gbl...
> > > Hi,
> > >
> > > "JC" <Josh@Network-Medics.Com> wrote in message
> > > news:eH5$jx4VDHA.3232@tk2msftngp13.phx.gbl...
> > > > Is there a seconds parameter that I can use for time to count
seconds
> > > > elapsed, for example, I want to use,
> > > >
> > > > if test1 = test2 then
> > > > seconds = 1
> > > > end if
> > > >
> > > > usage = test1 - test2
> > >
> > > The intrinsic Timer function returns the number of seconds (trustable
to
> > > hundreths) since midnight. Be careful of the rest to 0 at midnight.
> > >
> > > time1= timer
> > > wscript.sleep 3000
> > > time2= timer
> > > ' adjust if past midnight
> > > if (time2<time1) then time2= time2 +(60*60*24)
> > > wscript.echo time2- time1
> > >
> > > Joe Earnest
> > >
> > >
> >
> >
>
>



Re: Seconds Parameter by JC

JC
Thu Jul 31 13:54:26 CDT 2003

basically I want something in the script to start the timer, call it test,
when test is reached it starts the timer, then after 30 seconds it will
execute test2, how is this done?


"Robert Cohen" <jerrygarcia@gratefuldead.com> wrote in message
news:eeaZrM5VDHA.2340@TK2MSFTNGP10.phx.gbl...
> you want to use the timer function
>
>
> Returns the number of seconds that have elapsed since 12:00 AM (midnight).
>
> TimerRemarks
> The following example uses the Timer function to determine the time it
takes
> to iterate a For...Next loop N times:
>
> Function TimeIt(N)
> Dim StartTime, EndTime
> StartTime = Timer
> For I = 1 To N
> Next
> EndTime = Timer
> TimeIt = EndTime - StartTime
> End Function
> --
> Robert Cohen
> A legend in his own mind
> --
>
> "JC" <Josh@Network-Medics.Com> wrote in message
> news:#J97xC5VDHA.2156@TK2MSFTNGP11.phx.gbl...
> > One question though, suppose I want to start a second counter at 0 or 1
> does
> > not matter, and count the number of seconds that elapse until I tell it
to
> > stop?
> > "JC" <Josh@Network-Medics.Com> wrote in message
> > news:#BOq6$4VDHA.2316@TK2MSFTNGP09.phx.gbl...
> > > Awesome thank you both so much huge help !!!!!!!
> > >
> > > "Joe Earnest" <joeearnest@qwest.net> wrote in message
> > > news:uwCAs44VDHA.1600@TK2MSFTNGP09.phx.gbl...
> > > > Hi,
> > > >
> > > > "JC" <Josh@Network-Medics.Com> wrote in message
> > > > news:eH5$jx4VDHA.3232@tk2msftngp13.phx.gbl...
> > > > > Is there a seconds parameter that I can use for time to count
> seconds
> > > > > elapsed, for example, I want to use,
> > > > >
> > > > > if test1 = test2 then
> > > > > seconds = 1
> > > > > end if
> > > > >
> > > > > usage = test1 - test2
> > > >
> > > > The intrinsic Timer function returns the number of seconds
(trustable
> to
> > > > hundreths) since midnight. Be careful of the rest to 0 at midnight.
> > > >
> > > > time1= timer
> > > > wscript.sleep 3000
> > > > time2= timer
> > > > ' adjust if past midnight
> > > > if (time2<time1) then time2= time2 +(60*60*24)
> > > > wscript.echo time2- time1
> > > >
> > > > Joe Earnest
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Seconds Parameter by Robert

Robert
Thu Jul 31 14:25:11 CDT 2003

oh you mean you want to script to pause for 30 seconds. Is that correct.

do something
wait 30 seconds
do something else

if so, you just need to do wscript.sleep 30000

(30000 is 30 seconds)

or am I misunderstanding you
--
Robert Cohen
A legend in his own mind
--

"JC" <Josh@Network-Medics.Com> wrote in message
news:ef6NrU5VDHA.2224@TK2MSFTNGP09.phx.gbl...
> basically I want something in the script to start the timer, call it test,
> when test is reached it starts the timer, then after 30 seconds it will
> execute test2, how is this done?
>
>
> "Robert Cohen" <jerrygarcia@gratefuldead.com> wrote in message
> news:eeaZrM5VDHA.2340@TK2MSFTNGP10.phx.gbl...
> > you want to use the timer function
> >
> >
> > Returns the number of seconds that have elapsed since 12:00 AM
(midnight).
> >
> > TimerRemarks
> > The following example uses the Timer function to determine the time it
> takes
> > to iterate a For...Next loop N times:
> >
> > Function TimeIt(N)
> > Dim StartTime, EndTime
> > StartTime = Timer
> > For I = 1 To N
> > Next
> > EndTime = Timer
> > TimeIt = EndTime - StartTime
> > End Function
> > --
> > Robert Cohen
> > A legend in his own mind
> > --
> >
> > "JC" <Josh@Network-Medics.Com> wrote in message
> > news:#J97xC5VDHA.2156@TK2MSFTNGP11.phx.gbl...
> > > One question though, suppose I want to start a second counter at 0 or
1
> > does
> > > not matter, and count the number of seconds that elapse until I tell
it
> to
> > > stop?
> > > "JC" <Josh@Network-Medics.Com> wrote in message
> > > news:#BOq6$4VDHA.2316@TK2MSFTNGP09.phx.gbl...
> > > > Awesome thank you both so much huge help !!!!!!!
> > > >
> > > > "Joe Earnest" <joeearnest@qwest.net> wrote in message
> > > > news:uwCAs44VDHA.1600@TK2MSFTNGP09.phx.gbl...
> > > > > Hi,
> > > > >
> > > > > "JC" <Josh@Network-Medics.Com> wrote in message
> > > > > news:eH5$jx4VDHA.3232@tk2msftngp13.phx.gbl...
> > > > > > Is there a seconds parameter that I can use for time to count
> > seconds
> > > > > > elapsed, for example, I want to use,
> > > > > >
> > > > > > if test1 = test2 then
> > > > > > seconds = 1
> > > > > > end if
> > > > > >
> > > > > > usage = test1 - test2
> > > > >
> > > > > The intrinsic Timer function returns the number of seconds
> (trustable
> > to
> > > > > hundreths) since midnight. Be careful of the rest to 0 at
midnight.
> > > > >
> > > > > time1= timer
> > > > > wscript.sleep 3000
> > > > > time2= timer
> > > > > ' adjust if past midnight
> > > > > if (time2<time1) then time2= time2 +(60*60*24)
> > > > > wscript.echo time2- time1
> > > > >
> > > > > Joe Earnest
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Re: Seconds Parameter by Joe

Joe
Thu Jul 31 15:23:36 CDT 2003

Hi,

"JC" <Josh@Network-Medics.Com> wrote in message
news:uhaKct5VDHA.1816@TK2MSFTNGP09.phx.gbl...
> OK this is what I am trying to do,
>
> set events =
>
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery
> ("select * from __instancemodificationevent within 5 where targetinstance
> isa 'Win32_Processor'")
> Set NTEvent = events.nextevent
>
> if NTEvent.TargetInstance.LoadPercentage > 90 then
> (start counter for 30 seconds)
> if 30 or more seconds have passed then send me an email letting me know
that
> the server in question, for 30 seconds or more my processor has been at
90%
> or more utilization.
>
> All I want to do is know if a domain controller is being at 90% or more
> utilization for 30 seconds or more..

Robert's right that you're really after sleep and not a timer. You need to
pick an acceptable intervals for you (very short intervals eat up more CPU
resources) and run a loop:

'a continuous loop to check for usage every second
do: sleep 1000
if NTEvent.TargetInstance.LoadPercentage > 90 then

' start a secondary loop to test every half second
for iHalfSec= 1 to 60
sleep 500
if NTEvent.TargetInstance.LoadPercentage < 90 then _
exit for
next: if (iHalfSec>60) then ... 'send email
end if
loop

A for-next counter is incremented at each loop, so if it is not exited, the
final value will be one step greater than the final loop value.

Joe Earnest





Re: Seconds Parameter by JC

JC
Thu Jul 31 15:24:40 CDT 2003

But I dont want it to wait for 30 seconds then fire another alert, I want it
to fire the alert only if both the CPU is at 90% utilization and it is for
30 seconds, so I need a seconds counter (to count that 30 seconds has passed
while the CPU was at 90% or more utilization), I will then use

(I want both things to be true or nothing happens, not just simply wait for
30 seconds then continue)

if NTEvent.TargetInstance.LoadPercentage > 90 AND (30 seconds have passed)
then

(send email)

Please Help...

"Joe Earnest" <joeearnest@qwest.net> wrote in message
news:e1PmsC6VDHA.2360@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> "JC" <Josh@Network-Medics.Com> wrote in message
> news:uhaKct5VDHA.1816@TK2MSFTNGP09.phx.gbl...
> > OK this is what I am trying to do,
> >
> > set events =
> >
>
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery
> > ("select * from __instancemodificationevent within 5 where
targetinstance
> > isa 'Win32_Processor'")
> > Set NTEvent = events.nextevent
> >
> > if NTEvent.TargetInstance.LoadPercentage > 90 then
> > (start counter for 30 seconds)
> > if 30 or more seconds have passed then send me an email letting me know
> that
> > the server in question, for 30 seconds or more my processor has been at
> 90%
> > or more utilization.
> >
> > All I want to do is know if a domain controller is being at 90% or more
> > utilization for 30 seconds or more..
>
> Robert's right that you're really after sleep and not a timer. You need
to
> pick an acceptable intervals for you (very short intervals eat up more CPU
> resources) and run a loop:
>
> 'a continuous loop to check for usage every second
> do: sleep 1000
> if NTEvent.TargetInstance.LoadPercentage > 90 then
>
> ' start a secondary loop to test every half second
> for iHalfSec= 1 to 60
> sleep 500
> if NTEvent.TargetInstance.LoadPercentage < 90 then _
> exit for
> next: if (iHalfSec>60) then ... 'send email
> end if
> loop
>
> A for-next counter is incremented at each loop, so if it is not exited,
the
> final value will be one step greater than the final loop value.
>
> Joe Earnest
>
>
>
>



Re: Seconds Parameter by JC

JC
Thu Jul 31 16:10:51 CDT 2003

Thank you both so much for your help, I have enough info to finish my
script, again thank you both so much for your time!!!!


"Joe Earnest" <joeearnest@qwest.net> wrote in message
news:#p1wOY6VDHA.1620@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> "JC" <Josh@Network-Medics.Com> wrote in message
> news:#jBVGH6VDHA.624@TK2MSFTNGP10.phx.gbl...
> > But I dont want it to wait for 30 seconds then fire another alert, I
want
> it
> > to fire the alert only if both the CPU is at 90% utilization and it is
for
> > 30 seconds, so I need a seconds counter (to count that 30 seconds has
> passed
> > while the CPU was at 90% or more utilization), I will then use
> >
> > (I want both things to be true or nothing happens, not just simply wait
> for
> > 30 seconds then continue)
> >
> > if NTEvent.TargetInstance.LoadPercentage > 90 AND (30 seconds have
passed)
> > then
> >
> > (send email)
> >
>
> I think this does what you want. If you were to just check at initiation
> and 30 seconds, the usage might be >90% at those two points, but may well
> have been less in-between. So if you want 30 seconds of >90%, you need an
> interval to check during the 30-second period to make sure that it is >90%
> at each check.
>
> The script I gave you loops every second to check for >90% usage. If so,
it
> starts a thirty-second loop. Then if, and only if, that loop completes
> (i.e., doesn't exit because usage has fallen below 90% during the
30-second
> period), it sends an email.
>
> Joe Earnest
>
>
>



Re: Seconds Parameter by Robert

Robert
Thu Jul 31 16:17:18 CDT 2003

no problem :-)

--
Robert Cohen
A legend in his own mind
--

"JC" <Josh@Network-Medics.Com> wrote in message
news:etf35g6VDHA.2100@TK2MSFTNGP11.phx.gbl...
> Thank you both so much for your help, I have enough info to finish my
> script, again thank you both so much for your time!!!!
>
>
> "Joe Earnest" <joeearnest@qwest.net> wrote in message
> news:#p1wOY6VDHA.1620@TK2MSFTNGP12.phx.gbl...
> > Hi,
> >
> > "JC" <Josh@Network-Medics.Com> wrote in message
> > news:#jBVGH6VDHA.624@TK2MSFTNGP10.phx.gbl...
> > > But I dont want it to wait for 30 seconds then fire another alert, I
> want
> > it
> > > to fire the alert only if both the CPU is at 90% utilization and it is
> for
> > > 30 seconds, so I need a seconds counter (to count that 30 seconds has
> > passed
> > > while the CPU was at 90% or more utilization), I will then use
> > >
> > > (I want both things to be true or nothing happens, not just simply
wait
> > for
> > > 30 seconds then continue)
> > >
> > > if NTEvent.TargetInstance.LoadPercentage > 90 AND (30 seconds have
> passed)
> > > then
> > >
> > > (send email)
> > >
> >
> > I think this does what you want. If you were to just check at
initiation
> > and 30 seconds, the usage might be >90% at those two points, but may
well
> > have been less in-between. So if you want 30 seconds of >90%, you need
an
> > interval to check during the 30-second period to make sure that it is
>90%
> > at each check.
> >
> > The script I gave you loops every second to check for >90% usage. If
so,
> it
> > starts a thirty-second loop. Then if, and only if, that loop completes
> > (i.e., doesn't exit because usage has fallen below 90% during the
> 30-second
> > period), it sends an email.
> >
> > Joe Earnest
> >
> >
> >
>
>



Re: Seconds Parameter by Josh>

Josh>
Fri Aug 01 20:08:59 CDT 2003

Robert I am trying your way but it does not loop and exists after about 5
seconds, here it is, (I changed it to wscript.echo "email" for testing) what
am I doing wrong??

strComputer = "DC1"

set events =
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery
("select * from __instancemodificationevent within 5 where targetinstance
isa 'Win32_Processor'")
Set NTEvent = events.nextevent

sub testevent()

testevent
if NTEvent.TargetInstance.LoadPercentage > 90 then
wscript.sleep 30000
testevent
If NTEvent.TargetInstance.LoadPercentage > 90 then
wscript.echo "Email"
End If
End If

End Sub
"Robert Cohen" <jerrygarcia@gratefuldead.com> wrote in message
news:ek9V$k6VDHA.208@tk2msftngp13.phx.gbl...
> no problem :-)
>
> --
> Robert Cohen
> A legend in his own mind
> --
>
> "JC" <Josh@Network-Medics.Com> wrote in message
> news:etf35g6VDHA.2100@TK2MSFTNGP11.phx.gbl...
> > Thank you both so much for your help, I have enough info to finish my
> > script, again thank you both so much for your time!!!!
> >
> >
> > "Joe Earnest" <joeearnest@qwest.net> wrote in message
> > news:#p1wOY6VDHA.1620@TK2MSFTNGP12.phx.gbl...
> > > Hi,
> > >
> > > "JC" <Josh@Network-Medics.Com> wrote in message
> > > news:#jBVGH6VDHA.624@TK2MSFTNGP10.phx.gbl...
> > > > But I dont want it to wait for 30 seconds then fire another alert, I
> > want
> > > it
> > > > to fire the alert only if both the CPU is at 90% utilization and it
is
> > for
> > > > 30 seconds, so I need a seconds counter (to count that 30 seconds
has
> > > passed
> > > > while the CPU was at 90% or more utilization), I will then use
> > > >
> > > > (I want both things to be true or nothing happens, not just simply
> wait
> > > for
> > > > 30 seconds then continue)
> > > >
> > > > if NTEvent.TargetInstance.LoadPercentage > 90 AND (30 seconds have
> > passed)
> > > > then
> > > >
> > > > (send email)
> > > >
> > >
> > > I think this does what you want. If you were to just check at
> initiation
> > > and 30 seconds, the usage might be >90% at those two points, but may
> well
> > > have been less in-between. So if you want 30 seconds of >90%, you
need
> an
> > > interval to check during the 30-second period to make sure that it is
> >90%
> > > at each check.
> > >
> > > The script I gave you loops every second to check for >90% usage. If
> so,
> > it
> > > starts a thirty-second loop. Then if, and only if, that loop
completes
> > > (i.e., doesn't exit because usage has fallen below 90% during the
> > 30-second
> > > period), it sends an email.
> > >
> > > Joe Earnest
> > >
> > >
> > >
> >
> >
>
>



Re: Seconds Parameter by Robert

Robert
Fri Aug 01 06:43:19 CDT 2003


--
--

>
> sub testevent()
>
> testevent
> if NTEvent.TargetInstance.LoadPercentage > 90 then
> wscript.sleep 30000
> testevent
> If NTEvent.TargetInstance.LoadPercentage > 90 then
> wscript.echo "Email"
> End If
> End If
>
> End Sub

You modified the script incorrectly. Basically you have a subroutine and
the first thing you do, you call the same subroutine. So it starts sub
testevent and soon as it starts it calls test event and so on. There is no
way to get past it.

See with my script (which Ihaven't tested), calls for the sub routine.
After doing the subroutine the script continues at the if NTEvent line. It
tests and if over 90 it waits 30 seconds and then runs testevent again. It
then tests again to see if it is again over 90 and if so, will do the
wscipt.echo. Obviously, if the first time it does the if NTEvent isn't
above 90 it ends.

testevent
if NTEvent.TargetInstance.LoadPercentage > 90 then
wscript.sleep 30000
testevent
If NTEvent.TargetInstance.LoadPercentage > 90 then
wscript.echo "E-mail"
End If
End If

sub testevent()
set events
=GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuer
y
("select * from __instancemodificationevent within 5 where targetinstance
isa 'Win32_Processor'")
Set NTEvent = events.nextevent
End Sub




Re: Seconds Parameter by JC

JC
Fri Aug 01 08:43:52 CDT 2003

Oh ok, so then how can i get it to loop with a sub routine?


"Robert Cohen" <jerrygarcia@gratefuldead.com> wrote in message
news:#Ut27JCWDHA.1872@TK2MSFTNGP12.phx.gbl...
>
> --
> --
>
> >
> > sub testevent()
> >
> > testevent
> > if NTEvent.TargetInstance.LoadPercentage > 90 then
> > wscript.sleep 30000
> > testevent
> > If NTEvent.TargetInstance.LoadPercentage > 90 then
> > wscript.echo "Email"
> > End If
> > End If
> >
> > End Sub
>
> You modified the script incorrectly. Basically you have a subroutine and
> the first thing you do, you call the same subroutine. So it starts sub
> testevent and soon as it starts it calls test event and so on. There is
no
> way to get past it.
>
> See with my script (which Ihaven't tested), calls for the sub routine.
> After doing the subroutine the script continues at the if NTEvent line.
It
> tests and if over 90 it waits 30 seconds and then runs testevent again.
It
> then tests again to see if it is again over 90 and if so, will do the
> wscipt.echo. Obviously, if the first time it does the if NTEvent isn't
> above 90 it ends.
>
> testevent
> if NTEvent.TargetInstance.LoadPercentage > 90 then
> wscript.sleep 30000
> testevent
> If NTEvent.TargetInstance.LoadPercentage > 90 then
> wscript.echo "E-mail"
> End If
> End If
>
> sub testevent()
> set events
>
=GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuer
> y
> ("select * from __instancemodificationevent within 5 where targetinstance
> isa 'Win32_Processor'")
> Set NTEvent = events.nextevent
> End Sub
>
>
>



Re: Seconds Parameter by Dr

Dr
Fri Aug 01 12:17:03 CDT 2003

JRS: In article <uwCAs44VDHA.1600@TK2MSFTNGP09.phx.gbl>, seen in
news:microsoft.public.scripting.vbscript, Joe Earnest
<joeearnest@qwest.net> posted at Thu, 31 Jul 2003 12:11:11 :-
>
>The intrinsic Timer function returns the number of seconds (trustable to
>hundreths) since midnight.

In, I believe, WinNT & later, it steps every 10 ms. In my Win98 it
steps by 0.05 and 0.06 seconds. No doubt it reflects the MSDOS 18.2 Hz
clock there.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

Re: Seconds Parameter by Joe

Joe
Fri Aug 01 12:42:50 CDT 2003

Hi,

"Dr John Stockton" <spam@merlyn.demon.co.uk> wrote in message
news:WjjJkSCPCqK$Ew1a@merlyn.demon.co.uk...
> In, I believe, WinNT & later, it steps every 10 ms. In my Win98 it
> steps by 0.05 and 0.06 seconds. No doubt it reflects the MSDOS 18.2 Hz
> clock there.

Thanks. I wasn't aware of the Win9x difference.

Regards,
Joe Earnest




Re: Seconds Parameter by JC

JC
Fri Aug 01 14:24:17 CDT 2003

Can anyone help with my current broblem


Also in the order you have it, it keeps on giving me an error, "Object
required: 'NTEvent'" on this line (second line, first if/then) "if
NTEvent.TargetInstance.LoadPercentage > 90 then"

Shouldn't these be on the top so it has the NTEvent

"set events =
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery
("select * from __instancemodificationevent within 5 where targetinstance
isa 'Win32_Processor'")
Set NTEvent = events.nextevent"


"Joe Earnest" <joeearnest@qwest.net> wrote in message
news:uOPZfNFWDHA.2024@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> "Dr John Stockton" <spam@merlyn.demon.co.uk> wrote in message
> news:WjjJkSCPCqK$Ew1a@merlyn.demon.co.uk...
> > In, I believe, WinNT & later, it steps every 10 ms. In my Win98 it
> > steps by 0.05 and 0.06 seconds. No doubt it reflects the MSDOS 18.2 Hz
> > clock there.
>
> Thanks. I wasn't aware of the Win9x difference.
>
> Regards,
> Joe Earnest
>
>
>



Re: Seconds Parameter by Joe

Joe
Fri Aug 01 14:56:40 CDT 2003

Hi,

"JC" <Josh@Network-Medics.Com> wrote in message
news:uv0CCMGWDHA.1872@TK2MSFTNGP12.phx.gbl...
> Can anyone help with my current broblem
>
>
> Also in the order you have it, it keeps on giving me an error, "Object
> required: 'NTEvent'" on this line (second line, first if/then) "if
> NTEvent.TargetInstance.LoadPercentage > 90 then"
>
> Shouldn't these be on the top so it has the NTEvent
>
> "set events =
>
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery
> ("select * from __instancemodificationevent within 5 where targetinstance
> isa 'Win32_Processor'")
> Set NTEvent = events.nextevent"

It certainly seems that they should come first. You have to set your object
instance pointer before you can reference it. As I recall, without looking
back, I believe that Robert had put these lines in a procedure and was
calling the procedure before referencing the object. But you still need to
either pass the NTEvent object variable as a procedure argument or Dim it as
a global variable, for that to be effective.

Joe Earnest




Re: Seconds Parameter by JC

JC
Fri Aug 01 15:11:10 CDT 2003

So then you think I should use,

DIM NTEvent


"Joe Earnest" <joeearnest@qwest.net> wrote in message
news:ONetRYGWDHA.2276@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> "JC" <Josh@Network-Medics.Com> wrote in message
> news:uv0CCMGWDHA.1872@TK2MSFTNGP12.phx.gbl...
> > Can anyone help with my current broblem
> >
> >
> > Also in the order you have it, it keeps on giving me an error, "Object
> > required: 'NTEvent'" on this line (second line, first if/then) "if
> > NTEvent.TargetInstance.LoadPercentage > 90 then"
> >
> > Shouldn't these be on the top so it has the NTEvent
> >
> > "set events =
> >
>
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery
> > ("select * from __instancemodificationevent within 5 where
targetinstance
> > isa 'Win32_Processor'")
> > Set NTEvent = events.nextevent"
>
> It certainly seems that they should come first. You have to set your
object
> instance pointer before you can reference it. As I recall, without
looking
> back, I believe that Robert had put these lines in a procedure and was
> calling the procedure before referencing the object. But you still need
to
> either pass the NTEvent object variable as a procedure argument or Dim it
as
> a global variable, for that to be effective.
>
> Joe Earnest
>
>
>



Re: Seconds Parameter by JC

JC
Fri Aug 01 15:17:14 CDT 2003

Ok so I have this now, but how do I get it to loop so it runs continously?

strComputer = "DC5"

DIM NTEvent

testevent
if NTEvent.TargetInstance.LoadPercentage > 10 then
wscript.sleep 1
testevent
If NTEvent.TargetInstance.LoadPercentage > 10 then
wscript.echo "E-mail"
End If
End If

sub testevent()

set events =
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery
("select * from __instancemodificationevent within 5 where targetinstance
isa 'Win32_Processor'")
Set NTEvent = events.nextevent

End Sub
"Joe Earnest" <joeearnest@qwest.net> wrote in message
news:ONetRYGWDHA.2276@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> "JC" <Josh@Network-Medics.Com> wrote in message
> news:uv0CCMGWDHA.1872@TK2MSFTNGP12.phx.gbl...
> > Can anyone help with my current broblem
> >
> >
> > Also in the order you have it, it keeps on giving me an error, "Object
> > required: 'NTEvent'" on this line (second line, first if/then) "if
> > NTEvent.TargetInstance.LoadPercentage > 90 then"
> >
> > Shouldn't these be on the top so it has the NTEvent
> >
> > "set events =
> >
>
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecNotificationQuery
> > ("select * from __instancemodificationevent within 5 where
targetinstance
> > isa 'Win32_Processor'")
> > Set NTEvent = events.nextevent"
>
> It certainly seems that they should come first. You have to set your
object
> instance pointer before you can reference it. As I recall, without
looking
> back, I believe that Robert had put these lines in a procedure and was
> calling the procedure before referencing the object. But you still need
to
> either pass the NTEvent object variable as a procedure argument or Dim it
as
> a global variable, for that to be effective.
>
> Joe Earnest
>
>
>



Re: Seconds Parameter by Joe

Joe
Fri Aug 01 17:01:32 CDT 2003

Hi,

[snipped]
"JC" <Josh@Network-Medics.Com> wrote in message
news:#Yd4npGWDHA.216@TK2MSFTNGP11.phx.gbl...
> Ok so I have this now, but how do I get it to loop so it runs continously?

Try this revision. I'm not personally familiar with the query string
syntax, so I'm using the sub syntax that Robert used. You may have to play
with where you put the call to the sub in relation to the loop to get the
desired combination of notifications and emails.

---
option explicit
dim NTEvent, strComputer

' this doesn't seem to be used in your current WMI definition
strComputer = "DC5"

' here's your loop
do

' you want a background test every second????
wscript.sleep 1000

testEvent
if (NTEvent.TargetInstance.LoadPercentage>10) then

' I assume that the "1" was for testing,
' but 1 second is 1000 ms, 30 seconds is 30000 ms
wscript.sleep 1000

' I'm not sure whether to call the sub again here
' try it with and without the next line
testEvent

if (NTEvent.TargetInstance.LoadPercentage>10) then

' you need msgbox instead of wscript.echo to be
' able to break out the loop for testing
' otherwise you'll be trapped and unable to exit

' wscript.echo "E-mail"
if msgbox("E-mail", _
vbOkCancel, "Test Report")=vbCancel then _
exit do
end if
loop

sub testEvent ()
dim Events, sWMI, sQuery

sWMI= "winmgmts:{impersonationLevel=impersonate}"
sQuery= "select * from __instancemodificationevent " _
& "within 5 where targetinstance isa 'Win32_Processor'"

set Events = GetObject(sWMI).ExecNotificationQuery(sQuery)
set NTEvent = Events.nextEvent
end sub




Re: Seconds Parameter by Dr

Dr
Sun Aug 03 09:38:48 CDT 2003

JRS: In article <uOPZfNFWDHA.2024@TK2MSFTNGP12.phx.gbl>, seen in
news:microsoft.public.scripting.vbscript, Joe Earnest
<joeearnest@qwest.net> posted at Fri, 1 Aug 2003 11:42:50 :-
>Hi,
>
>"Dr John Stockton" <spam@merlyn.demon.co.uk> wrote in message
>news:WjjJkSCPCqK$Ew1a@merlyn.demon.co.uk...
>> In, I believe, WinNT & later, it steps every 10 ms. In my Win98 it
>> steps by 0.05 and 0.06 seconds. No doubt it reflects the MSDOS 18.2 Hz
>> clock there.
>
>Thanks. I wasn't aware of the Win9x difference.

Page <URL:http://www.merlyn.demon.co.uk/vb-dates.htm> now includes code
that measures the Timer interval and a CMJD<->date converter; also code
for ISO Week Number and Easter Sunday.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.