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