Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBScript Check if folder exists

Posted on 2010-11-17
8
Medium Priority
?
1,852 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 93

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 93

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 1500 total points
ID: 34155903
0
 

Author Closing Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

670 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