• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 719
  • Last Modified:

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
0
charlespliler
Asked:
charlespliler
  • 2
1 Solution
 
charlesplilerAuthor Commented:
I have taken ownership of the Directory and files as well to no avail.
0
 
Ron MalmsteadInformation Services ManagerCommented:
Is it possible the file is still in use when attempting to delete ?
0
 
charlesplilerAuthor Commented:
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??
0
 
sgdoughtCommented:
Add this to the top or your script:

On Error resume next


Then when it kicks an error it will continue.

Comment it out if you need to troubleshoot the script, the uncomment when your are ready to put the script inot production.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now