Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Receive Msg "Permission Denied" 800A0046

Status
Not open for further replies.

samyiel

MIS
Mar 14, 2003
3
0
0
US
First off, I am still fairly new to VBscript and am seeking help.

I think I have seen some nfo on this forum before, but couldn't find it again. No matter what I try, I always receive "Permission Denied" on the last line of my script when attempting to deleting a file. I checked Microsoft's site, but none of the fixes worked and most deal with ASP. The script is running under an admin account on the server (Win 2000) and the permissions on the files are default, nothing special. This seems like it should be sooooo simple and it's driving me crazy!! Here is an example of my code - thanks in advance for any information provided.

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("E:\Folder\subfolder\*.unv")
objFSO.DeleteFile("E:\Folder2\subfolder\*.rep")

In this example, I would reveive the error message "800A0046" on line "3."
 
samyiel:

What is the permission of the IUSR_"computername" on the above mentioned folders. This might or might not be the problem.

Thanks,
[yinyang]
Patrick
 
I will try this out and let you know. Thanks for the repsonse - hope it works.
 
You have to be careful, the MS documentation isn't perfect.

For one thing:
Code:
objFSO.DeleteFile("E:\Folder\subfolder\*.unv")
Is incorrect. They make this mistake in many places in the documentation, probably because:

A. The guy wrote wrote it was a C or a Javascript person.

B. It never got caught because you'll get away with it sometimes.

The correct statement looks like:
Code:
objFSO.DeleteFile "E:\Folder\subfolder\*.unv"
This would normally work because the parentheses are treated as redundant expression-grouping parens.

Why do you care? How might this help you?

Getting to it...

The DeleteFile method of the FSO has two parameters. The first is required, and is called filespec and you have supplied that. The second is called force and this may be what you need. If force is True then even files with the "read only" attribute are removed.

Perhaps this is what you're running into?

Where the syntax matters is that:
Code:
objFSO.DeleteFile("E:\Folder\subfolder\*.unv", True)
... will give you a VBScript syntax error. Those parentheses do not belong there! Instead you'll want to use something like:
Code:
objFSO.DeleteFile "E:\Folder\subfolder\*.unv", True
This is the proper syntax for a method call that isn't being used as a function (isn't returning a value).


So... this was long-winded, but you might look to see if some of the files you want to delete are marked "read only."
 
dilettante,

I meant to respond back to this awhile and almost forgot. Your suggestion has resolved the issue and the script is working to my needs now. Interesting that the MS KB article was "misleading," but it happens.

Thank you for sharing the information and I appriciate your replies.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top