#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    157
    Rep Power
    89

    VBSript - FileSystemObject


    Hello,

    I have the following code which is part of a recursive function

    Set ObjFolder = objFSO.GetFolder(strFolderPath)
    Set Files = ObjFolder.files
    msgbox Files.count

    If all NTFS permissions are removed from the folder strFolderPath then the script completely breaks out of the function.

    The Files object is being created however when I try to use it in any way the problem happens.

    How can I test if the script has access to the folder in questions to error trap this?

    Please do not suggest granting permission to the folder as they were revoked deliberately.

    Cheers
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,428
    Rep Power
    4539
    You need to give adequate permissions to the folder in question.
    ======
    Doug G
    ======
    The man who doesn't read good books has no advantage over the man who can't read them.
    --Mark Twain
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    157
    Rep Power
    89
    Originally Posted by Doug G
    You need to give adequate permissions to the folder in question.
    Hopefully that was sarcasm.

    It ended up being that on error resume next was required in the function and not just at the start of the script.
  6. #4
  7. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,428
    Rep Power
    4539
    All on error resume next will do for you is hide any program errors, including the error you were asking about. Unless you test the err status after every statement on error resume next just is a bug creator imho. And if your recursive function is calling on error resume next multiple times without resetting error trapping first my guess is you may have another problem waiting to emerge if error trapping is handled in any kind of stack.
    ======
    Doug G
    ======
    The man who doesn't read good books has no advantage over the man who can't read them.
    --Mark Twain
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    157
    Rep Power
    89
    I am checking the err status. The purpose of the script is to find problematic folders.
  10. #6
  11. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,428
    Rep Power
    4539
    Originally Posted by TASB
    I am checking the err status. The purpose of the script is to find problematic folders.
    In that case, on error resume next is the tool you want to use. If it were me, if you are setting the error trap in a recursive function I'd turn it back off immediately in the same iteration (with on error goto 0).
    ======
    Doug G
    ======
    The man who doesn't read good books has no advantage over the man who can't read them.
    --Mark Twain

IMN logo majestic logo threadwatch logo seochat tools logo