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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permission denied error

Status
Not open for further replies.

EzehM

Programmer
Feb 27, 2003
86
GB
I have a script that tries to delete a file. It however returns the following: Microsoft VBScript runtime error: Permission denied.

My questions are
1. How can I write a script that uses DeleteFile, and ensure that the script doesnt exit if it encounters a problem trying to delete the file.
2. If (1) is not possible, how can I ensure that the shell Cscript.exe returns a non-zero error code anytime it encounters a runtime error

Thanks
Milton
 
On error resume next

'Try your deletefile routine

then text after the routine if an error happened

if err.number>0 then
'Error happened, do something
end if "did you just say Minkey?, yes that's what I said."

MrGreed
 
This was just covered in the past couple weeks in thread329-501143. Often you can get a quicker answer by doing a forum search before asking the same question again.

This particular error is often the result of trying to delete a read-only file. The way you get around it is to pass the DeleteFile method a value of True for the second optional parameter force.

Have you tried reading the Windows Script documentation from yet? That site offers a comprehensive downloadable reference document there that is very helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top