cahillj
asked on
VBscript editing, my script bombs out when going to a folder it doesnt have rights to. need to be able to skip it
i have a code below. it goes through all the folders but when it gets to the folder it doesnt have rights to, it gets killed. i want it to be skip that folder it doesnt have right to and move to the next folders....
Set objShell = CreateObject("WScript.Shell")
strProfile = objShell.ExpandEnvironmentStrings("%USERPROFILE%")
strFolder = strProfile & "Cookies"
intDaysOld = 60
dteDate = DateAdd("d", intDaysOld, Now)
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each objFile In objFSO.GetFolder(strFolder).Files
If objFile.DateLastModified < dteDate Then
On Error Resume Next
objFSO.DeleteFile objFile.Path, True
Err.Clear
On Error GoTo 0
End If
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER