Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Script error 800a0046 Permission Denied

Posted on 2011-03-10
4
Medium Priority
?
705 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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

647 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