Hi All,
I have two questions. First, we wrote a script to monitor file server
response time. But datediff() function can only calculate time difference in
seconds. We are asked to provide data in mini-second. Is this possible in
VBScript? Or, i have to use vb.net?
2nd question, we wrote a script to list file service connection
information on a fie server, then try to check virus defination file on
connected client using WMI. But some of this client is not in our domain.
When this occurs, the script tale very long time to retry. Is is possible to
set a timeout value before create a wmi connection?
Thank you very much for your time and any help.

Eric Wu

Re: Calculate time difference in mini-second with VBScript by Shenan

Shenan
Sun Jan 28 19:17:01 CST 2007

Eric Wu wrote:
> I have two questions. First, we wrote a script to monitor file
> server response time. But datediff() function can only calculate
> time difference in seconds. We are asked to provide data in
> mini-second. Is this possible in VBScript? Or, i have to use vb.net?
> 2nd question, we wrote a script to list file service connection
> information on a fie server, then try to check virus defination
> file on connected client using WMI. But some of this client is not
> in our domain. When this occurs, the script tale very long time to
> retry. Is is possible to set a timeout value before create a wmi
> connection? Thank you very much for your time and any help.

How Can I Determine How Long It Takes a Script to Run?
http://labs.microsoft.com/technet/scriptcenter/resources/qanda/aug04/hey0818.mspx

Quote from the Scripting Guy...
"In case you?re wondering, you can only measure running times to the nearest
second; you can?t calculate times in microseconds or milliseconds or
anything crazy like that. That might sound like a limitation, but look at it
this way: if your script can complete in less than a second then you really
don?t have much to worry about, do you?"

As for the second question - I do not have an answer at this time.. :-(

--
Shenan Stanley
MS-MVP
--
How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html



Re: Calculate time difference in mini-second with VBScript by mayayana

mayayana
Sun Jan 28 21:17:17 CST 2007


> I have two questions. First, we wrote a script to monitor file server
> response time. But datediff() function can only calculate time difference
in
> seconds. We are asked to provide data in mini-second. Is this possible in
> VBScript? Or, i have to use vb.net?

You mean milliseconds (ms)? 1/1,000?

You can get a time measurement function in ms
here if you want to use a 3rd-party component.
http://www.jsware.net/jsware/scripts.php3#jssys

See the timer functions in the JSSys3.dll component.

I wonder how realistic that is for your purpose, though.
The time required to call the component, combined
with the very slow speed of a VBScript that has to be
interpreted by WScript.exe, is going to make your
measurement inaccurate. I really don't know how
inaccurate, but I'd be surprised if anything closer than
the nearest 1/4 second could be measured in VBScript.
I don't know about VB.Net, but I imagine that's also probably
fairly clunky for doing things like measuring in ms.



Re: Calculate time difference in mini-second with VBScript by Paul

Paul
Mon Jan 29 10:59:52 CST 2007


"Eric Wu" <wugh@ms21.hinet.net> wrote in message
news:OLlsnH0QHHA.1200@TK2MSFTNGP04.phx.gbl...
> Hi All,
> I have two questions. First, we wrote a script to monitor file server
> response time. But datediff() function can only calculate time difference
> in
> seconds. We are asked to provide data in mini-second. Is this possible in
> VBScript? Or, i have to use vb.net?
> 2nd question, we wrote a script to list file service connection
> information on a fie server, then try to check virus defination file on
> connected client using WMI. But some of this client is not in our domain.
> When this occurs, the script tale very long time to retry. Is is possible
> to
> set a timeout value before create a wmi connection?
> Thank you very much for your time and any help.
>
> Eric Wu
>
Hi,
I can't help with your second question.
On the timer question, plain VBScript does not have a way to access time
with less than 1 second resolution. The windows OS has timers with very
high resolution, but VBScript cannot directly get to them. There are free
COM objects that can access a higher resolution timer. One, called ASPTime,
is avalable here: http://www.cs.niu.edu/%7Ez951259/comlinks.html.

The Windows timer used by ASPTime has a variable resolution. On NT-type
systems ( for example, W2K & newer), it defaults to 10 milliseconds, but can
be as high as 1 millisecond, depending on the highest resolution currently
being used by any running application. So the trick is to guarantee its
being at 1 millisecond by running some little application, like running a
tiny HTML file with just this in the body:
<body>
<bgsound src="ding.wav" loop=0>
</body>
The 'ding' lasts under a second, but until you close this HTML file, the
sound software's request for 1 millisecond resolution remains in effect, so
ASPTime can get this resolution.

-Paul Randall



Re: Calculate time difference in mini-second with VBScript by Bob

Bob
Mon Jan 29 18:16:28 CST 2007

Paul Randall wrote:

> On the timer question, plain VBScript does not have a way to access time
> with less than 1 second resolution.

timer() most certainly *does*


Bob
--

Re: Calculate time difference in mini-second with VBScript by Bob

Bob
Mon Jan 29 18:49:05 CST 2007

Eric Wu wrote:
> Hi All,
> I have two questions. First, we wrote a script to monitor file server
> response time. But datediff() function can only calculate time difference in
> seconds. We are asked to provide data in mini-second. Is this possible in
> VBScript? Or, i have to use vb.net?

DateDiff() can't help you get all the way there, but you can do your own math
for the fractions.
Assuming you have some /source/ for data including fractional seconds.


I don't propose that the following is any example of great scripting, but it
does show a way to construct a sub-one-second 'version' of Now(), testing
it enough times to show that Timer() appears to be adequately synchronized
with Now() - at least when the calls are consecutive.


t2=timer
t2 = t2 - fix(t2)
do while t2 < 0.8
'waste time until the second is about to change
'so the demo can show values on both sides of the change
wscript.sleep 5
t2=timer
t2 = t2 - fix(t2)
loop

for i = 1 to 30
'include enough samples to observe alignment
t1 = now
t2 = timer
t2 = mid( (t2 - fix(t2)),2)
t1 = formatdatetime(t1,vblongtime)
t1 = left(t1,len(t1)-3)
msg = msg & t1 & t2 & vbcrlf
wscript.sleep 10
next
msgbox msg


Bob

Re: Calculate time difference in mini-second with VBScript by Eric

Eric
Mon Jan 29 21:04:44 CST 2007

Hi All,
Thank you very much for every kindly help and suggestion. Based on
informations i've got here, now i can proof my file server works well with
my users. The return value is less than their request( < 250ms). Script as
follows.

By the way, i still trying to find a way to solve the wait time for WMI
delay time, looks like 2 seconds. I've tried "MaxWaitOnClientObjects"
property of Win32_WMISetting, it can be change in W2K with SP4, but didn't
work. At windows 2003 with SP1, i got null value from default setting. I got
no error when change this value on W2003, but still not working.
Thank you very much for every help and suggestion again.
Eric Wu



Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
t1 = Timer
'AP_Process.TXT is a 1Mb text file used to measure file server response time
on remote file creation, L: is a share disk on my file server
objFSO.CopyFile "D:\Data\FileServer\AP_Process.TXT" , "L:\",
OverwriteExisting
t2 = Timer
vTimeDiff = t2 - t1
Set objFSO = Nothing
Wscript.Echo vTimeDiff







"Eric Wu" <wugh@ms21.hinet.net> ¦b¶l¥ó
news:OLlsnH0QHHA.1200@TK2MSFTNGP04.phx.gbl ¤¤¼¶¼g...
> Hi All,
> I have two questions. First, we wrote a script to monitor file server
> response time. But datediff() function can only calculate time difference
in
> seconds. We are asked to provide data in mini-second. Is this possible in
> VBScript? Or, i have to use vb.net?
> 2nd question, we wrote a script to list file service connection
> information on a fie server, then try to check virus defination file on
> connected client using WMI. But some of this client is not in our domain.
> When this occurs, the script tale very long time to retry. Is is possible
to
> set a timeout value before create a wmi connection?
> Thank you very much for your time and any help.
>
> Eric Wu
>
>



Re: Calculate time difference in mini-second with VBScript by Paul

Paul
Mon Jan 29 23:20:11 CST 2007


"Bob O`Bob" <filterbob@yahoogroups.com> wrote in message
news:eU6%23yPARHHA.412@TK2MSFTNGP02.phx.gbl...
> Paul Randall wrote:
>
>> On the timer question, plain VBScript does not have a way to access time
>> with less than 1 second resolution.
>
> timer() most certainly *does*
>
>
> Bob
> --

I stand corrected. Back on Jan 11, 2003, Michael Harris posted some code
and his results:
<quote>
But this much simpler test consistently gives .007812500 as the smallest
non-zero difference between 2 consecutive timer() calls over a set of
100,000 pairs (I even did a test with 1 million pairs with the same
results). </quote>

-Paul Randall