Solved

Script error 800a0046 Permission Denied

Posted on 2011-03-10
4
694 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Malmstead
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 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