Solved

Script error 800a0046 Permission Denied

Posted on 2011-03-10
4
685 Views
Last Modified: 2012-05-11
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
Comment
Question by:charlespliler
  • 2
4 Comments
 

Author Comment

by:charlespliler
ID: 35098958
I have taken ownership of the Directory and files as well to no avail.
0
 
LVL 25

Expert Comment

by:Ron M
ID: 35098974
Is it possible the file is still in use when attempting to delete ?
0
 

Author Comment

by:charlespliler
ID: 35099109
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
 
LVL 5

Accepted Solution

by:
sgdought earned 500 total points
ID: 35100664
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now