I have a script that scans subdirectories recursively and deletes files older than X date. Because permissions are incorrectly set on some folders, I’ve had to insert an “On Error Resume” into the code as well, where the error occurs.
However, the problem occurs when I do an if statement…
if (Err.Number > 0)
{
MsgBox("Permission denied on....")
}
It seems that despite the fact that the script throws an error when it can’t delete a file or get a folder’s contents, Err.Number isn’t increasing. Is there a better way to go about doing this?
The problem is likely due to this comparison
Err.Number > 0. The assumption here is that error numbers are postive numbers. However this is actually rarely true. You should be usingErr.Number <> 0.