Link to home
Start Free TrialLog in
Avatar of charlespliler
charlesplilerFlag for United States of America

asked on

Script error 800a0046 Permission Denied

I have a script to delete files older than 15 minutes and it works great except on a couple Servers. I run it as a Domain Admin and get this error
 Script: C;\FileCopy\test.vbs
Line:  8
Char:  9
Error:  Permission denied
Code: 800a0046
Source:  Microsoft VBScript runtime error

here is the script

Dim fso, f, f1, fc, result
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder("D:\GCTI\logs")
   Set fc = f.Files
   For Each f1 in fc
     result = DateDiff("n",f1.DateLastModified,Now)
    If result > 15 Then
        f1.Delete
    End If
   Next
   Set fso = Nothing
   Set f = Nothing
   Set fc = Nothing

PLEASE HELP
Avatar of charlespliler
charlespliler
Flag of United States of America image

ASKER

I have taken ownership of the Directory and files as well to no avail.
Avatar of Ron Malmstead
Is it possible the file is still in use when attempting to delete ?
There are multiple files in the directory, is there something to add to the script to have it skip over a file if its in use and move on to the next??
ASKER CERTIFIED SOLUTION
Avatar of sgdought
sgdought

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial