Hi all
I have written this script to report on the files in certain folder
and in its subfolders.
It works fine but it gives an error if the folder it is trying to
access does not have NTFS permissions for the user in whose context
the script is run.
I have tried inserting the line "On Error Resume Next" and this makes
so that no error is genrated but still the script stops recursing into
the folders and exits.
How can I make so that if the script does not have access to a
subfolder it skips it and continues to attempt accessing the other
subfolders???
Thanks!!!
' *** Last access date for files in a folder and in its subfolders ***
on error resume next
Set shell = Wscript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = FSO.GetFolder("c:\foldert")
Set REPORTFILE = fso.CreateTextFile("REPORT.csv")
call Recurse(objfolder)
Sub Recurse(objFolder)
For Each MYFILE In objfolder.Files
MYLINE = objfolder.path & "," & MYFILE.Name & "," &
MYFILE.DateLastAccessed & "," & MYFILE.Size
REPORTFILE.writeline MYLINE
Next
For each objSubFolder in objFolder.SubFolders
Recurse(objSubfolder)
Next
End Sub
REPORTFILE.close