Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript Check if folder exists

Posted on 2010-11-17
8
Medium Priority
?
1,863 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 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
Industry Leaders: 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

971 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