Enumerate Folders Error 
Author Message
 Enumerate Folders Error

I'm trying to write a script that will enumerate folders on a PC and write
them to a text file.

Everything works fine except if you put in c:\ to search it errors out when
it gets to the system volume information folder because of security rights
or something.  How would I change the script so that it just skips any
folder that gives it problems.  I've added on error resume next, but then
the script just quits with no error when it gets to the sysvol.  How do I
make it keep going to the next folder?

Below is the code:
***************************************************
Option Explicit

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  Dim FSob
  Dim filespec
  Dim Fc
  Dim oFolder
  Dim cFolder
  Dim sUnit

  On Error Resume Next
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

'*************************
 filespec = "c:\"
'*************************

  Set FSob = CreateObject("Scripting.FileSystemObject")
  Set Fc = FSob.CreateTextFile("FolderList.TXT", True)
  writefile(filespec)
  Fc.Close

'----------------------------------------------------------
  Public Function WriteFile(filespec)
 Set oFolder = FSob.GetFolder(filespec)
 Set cFolder = oFolder.SubFolders

 Fc.Writeline (oFolder.path)

 For Each sUnit in cFolder
    WriteFile(sUnit)
 Next
  End Function
'-----------------------------------------------------------
***************************************************
Thanks,
Terry



Tue, 29 Nov 2005 01:25:15 GMT  
 Enumerate Folders Error
Nevermind, I found that by putting the On Error Resume Next inside the
function instead of up top it works fine and continues on.
Terry


Quote:
> I'm trying to write a script that will enumerate folders on a PC and write
> them to a text file.

> Everything works fine except if you put in c:\ to search it errors out
when
> it gets to the system volume information folder because of security rights
> or something.  How would I change the script so that it just skips any
> folder that gives it problems.  I've added on error resume next, but then
> the script just quits with no error when it gets to the sysvol.  How do I
> make it keep going to the next folder?

> Below is the code:
> ***************************************************
> Option Explicit

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Quote:

>   Dim FSob
>   Dim filespec
>   Dim Fc
>   Dim oFolder
>   Dim cFolder
>   Dim sUnit

>   On Error Resume Next

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

- Show quoted text -

Quote:

> '*************************
>  filespec = "c:\"
> '*************************

>   Set FSob = CreateObject("Scripting.FileSystemObject")
>   Set Fc = FSob.CreateTextFile("FolderList.TXT", True)
>   writefile(filespec)
>   Fc.Close

> '----------------------------------------------------------
>   Public Function WriteFile(filespec)
>  Set oFolder = FSob.GetFolder(filespec)
>  Set cFolder = oFolder.SubFolders

>  Fc.Writeline (oFolder.path)

>  For Each sUnit in cFolder
>     WriteFile(sUnit)
>  Next
>   End Function
> '-----------------------------------------------------------
> ***************************************************
> Thanks,
> Terry



Tue, 29 Nov 2005 06:25:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Enumerating All Folders/Sub Folders

2. Enumerate a Folder and it's Sub Folders

3. How to enumerate subfolders in Public Folder Favorite ?

4. enumerate all folders at same level as inbox

5. Enumerate Messages in MAPI Folders

6. Enumerating folders

7. Enumerate Files and Folders -- Please Help!

8. Enumerating Shared Folders

9. Help, I cannot get all Share Folders enumerated

10. Help, I cannot get all Share Folders enumerated

11. Enumerating a folder's files using fileSystemObject

12. Enumerate Folders ?

 

 
Powered by phpBB® Forum Software