Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Faster way to do '.FolderExists' ?

Reply
 
Old 08-05-2008   #1 (permalink)
Dick


 
 

Faster way to do '.FolderExists' ?

I have a script that on occasion I need to test if a folder exists on
another server on the LAN. I use a statement such as:

If oFso.FolderExists("\\Server1\xyz") Then

I find that if the server is indeed powered on that the response is almost
instantaneous. However, if the server is not available, it appears to take
15-20 seconds before the script resumes. I presume that the code is going
thru an error retry procedure. This can get tedious if you have twenty
servers to test.

Has anyone come up with a quicker way to test if a folder is available in
VBScript?

Thanks...

Dick


My System SpecsSystem Spec
Old 08-05-2008   #2 (permalink)
mr_unreliable


 
 

Re: Faster way to do '.FolderExists' ?

Dick, have you tried "ping"? That might beat
a 10 sec wait.

Note: if you don't have a "ping" script handy,
you can find one here. Search with:

http://groups.google.com/advanced_search

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)


Dick wrote:
Quote:

> I have a script that on occasion I need to test if a folder exists on
> another server on the LAN. I use a statement such as:
>
> If oFso.FolderExists("\\Server1\xyz") Then
>
> I find that if the server is indeed powered on that the response is
> almost instantaneous. However, if the server is not available, it
> appears to take 15-20 seconds before the script resumes. I presume that
> the code is going thru an error retry procedure. This can get tedious
> if you have twenty servers to test.
>
> Has anyone come up with a quicker way to test if a folder is available
> in VBScript?
>
> Thanks...
>
> Dick
My System SpecsSystem Spec
Old 08-05-2008   #3 (permalink)
Dick


 
 

Re: Faster way to do '.FolderExists' ?

Thanks, I'll give that a try.

Dick

"mr_unreliable" <kindlyReplyToNewsgroup@xxxxxx> wrote in message
news:eYY0BM09IHA.4952@xxxxxx
Quote:

> Dick, have you tried "ping"? That might beat
> a 10 sec wait.
>
> Note: if you don't have a "ping" script handy,
> you can find one here. Search with:
>
> http://groups.google.com/advanced_search
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
> the answers will be applicable to the questions)
>
>
> Dick wrote:
Quote:

>> I have a script that on occasion I need to test if a folder exists on
>> another server on the LAN. I use a statement such as:
>>
>> If oFso.FolderExists("\\Server1\xyz") Then
>>
>> I find that if the server is indeed powered on that the response is
>> almost instantaneous. However, if the server is not available, it
>> appears to take 15-20 seconds before the script resumes. I presume that
>> the code is going thru an error retry procedure. This can get tedious if
>> you have twenty servers to test.
>>
>> Has anyone come up with a quicker way to test if a folder is available in
>> VBScript?
>>
>> Thanks...
>>
>> Dick
My System SpecsSystem Spec
Old 08-06-2008   #4 (permalink)
Al Dunbar


 
 

Re: Faster way to do '.FolderExists' ?

Even pinging 20 servers takes a certain amount of time. An alternate method
would be to have your script execute the net view command, and search for
the server names in its output.

If your servers are generally on or off and not often changing between those
two states, this can save a lot of time, even more so with a larger number
of servers to process.

/Al

"Dick" <rsutton43@xxxxxx> wrote in message
news:e$3qAc09IHA.2196@xxxxxx
Quote:

> Thanks, I'll give that a try.
>
> Dick
>
> "mr_unreliable" <kindlyReplyToNewsgroup@xxxxxx> wrote in message
> news:eYY0BM09IHA.4952@xxxxxx
Quote:

>> Dick, have you tried "ping"? That might beat
>> a 10 sec wait.
>>
>> Note: if you don't have a "ping" script handy,
>> you can find one here. Search with:
>>
>> http://groups.google.com/advanced_search
>>
>> cheers, jw
>> ____________________________________________________________
>>
>> You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
>> the answers will be applicable to the questions)
>>
>>
>> Dick wrote:
Quote:

>>> I have a script that on occasion I need to test if a folder exists on
>>> another server on the LAN. I use a statement such as:
>>>
>>> If oFso.FolderExists("\\Server1\xyz") Then
>>>
>>> I find that if the server is indeed powered on that the response is
>>> almost instantaneous. However, if the server is not available, it
>>> appears to take 15-20 seconds before the script resumes. I presume that
>>> the code is going thru an error retry procedure. This can get tedious
>>> if you have twenty servers to test.
>>>
>>> Has anyone come up with a quicker way to test if a folder is available
>>> in VBScript?
>>>
>>> Thanks...
>>>
>>> Dick
>

My System SpecsSystem Spec
Old 08-06-2008   #5 (permalink)
KGLovatt


 
 

Re: Faster way to do '.FolderExists' ?

Here's a script that I use to connect to the C$ share on remote
machines,
it pings the remote machine once and waits 1 second for a response.
On the line "ping -n 1 -w 1000" the -w tells it how many
miliseconds to wait and the -n tells it how many times to send the
ping, so you could alter those to suit your needs

strComputer = InputBox _
("Enter the Asset Tag of the computer you want to connect to :", _
"Enter Computer Name")

If strComputer = "" Then
Wscript.Quit
End If

Set WshShell = WScript.CreateObject("WScript.Shell")
Ping = WshShell.Run("ping -n 1 -w 1000 " & strComputer, 0, TRUE)

If Ping = 0 Then
' ***** If we get to here then it responded to the ping
strHostName = "\\" & strComputer & "\c$"
Set objShell = CreateObject("WScript.Shell")
strCommand = "explorer " & strHostName
Set objExecObject = objShell.Exec(strCommand)

Else
' ***** if we get to here then it didn't respond to the ping
Wscript.Echo strComputer & " could not be reached."

End If
My System SpecsSystem Spec
Old 08-06-2008   #6 (permalink)
Dick


 
 

Re: Faster way to do '.FolderExists' ?

Thanks to all who responded.

mr_unreliable and LGLovatt ideas on using 'ping' worked great. They were
trivial to implement so I'm using them as we speak.

Al Dunbar, thanks for the idea of using Net View. That certainly picked my
interest in that I get all the servers that are on at one time. Then I can
scan for each as I need them. I'm playing with that idea now while I'm
using ping to solve my immediate problem, today.

Thanks again...

Dick


"Dick" <rsutton43@xxxxxx> wrote in message
news:uigQFsy9IHA.1428@xxxxxx
Quote:

>I have a script that on occasion I need to test if a folder exists on
>another server on the LAN. I use a statement such as:
>
> If oFso.FolderExists("\\Server1\xyz") Then
>
> I find that if the server is indeed powered on that the response is almost
> instantaneous. However, if the server is not available, it appears to
> take 15-20 seconds before the script resumes. I presume that the code is
> going thru an error retry procedure. This can get tedious if you have
> twenty servers to test.
Quote:

>> Has anyone come up with a quicker way to test if a folder is available in
> VBScript?
>
> Thanks...
>
> Dick
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
My 32 bit faster? General Discussion
FolderExists and UNC path VB Script
Which is faster Vista General
Vista MC vs WMP. How come WMC is so much faster? Vista music pictures video
what's the faster one... Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46