Solved

VBScript Check if folder exists

Posted on 2010-11-17
8
1,793 Views
Last Modified: 2012-05-11
I have a list of UNC Paths that I want to go through to see if each one exists or not so I can filter out the ones that dont exists.

The problem I am having is when I come to a UNC Path that exists (but I do not have access to) the VBScript gives me an Error 76 (Path not found) so objFSO.FolderExists will return a FALSE.

Is there another way to find out if a folder exists or not but can also differenciate between paths that dont exists and paths that exist but I do not have access to?

Thanks
0
Comment
Question by:tr57285
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34155656
>>Is there another way to find out if a folder exists or not but can also differenciate between paths
>>that dont exists and paths that exist but I do not have access to?


Not by using the FileSystemObject, I'm afraid :(
0
 

Author Comment

by:tr57285
ID: 34155771
ok, can you give me another way?
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34155804
I cannot, but it stands to reason that the only way you are going to be able to do this is to have the VBScript execute using a login that DOES have proper access rights to the folder.
0
 
LVL 7

Expert Comment

by:rogerard
ID: 34155805
Then create a function to check for it:
Private Function issubform(ByVal frm As Form) As Boolean
    On Error GoTo ErrorCheck
    issubform = True
    If Me.Parent <> "" Then
        issubform = True
    End If
    Exit Function

ErrorCheck:
    If Err.Number = 2452 Then
        issubform = False
    End If
          
End Function

Open in new window

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 7

Expert Comment

by:rogerard
ID: 34155834
Sorry....  posted to wrong page  :(
0
 
LVL 10

Expert Comment

by:GlobaLevel
ID: 34155841
I have found that if you are looping thru UNC paths in vbscript...it hangs after it finds the first one...then throws the error you provide...and if you have to kill the script..eachtime to sarch the next UNC path...why have the program to begin with...

you would be better off with WMI...this can get you started...
http://msdn.microsoft.com/en-us/library/aa389290(VS.85).aspx
0
 
LVL 7

Accepted Solution

by:
rogerard earned 500 total points
ID: 34155903
0
 

Author Closing Comment

by:tr57285
ID: 36222515
Exactly what I was looking for.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now