[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 716
  • 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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

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