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

Deleting read only files 1

Status
Not open for further replies.

theniteowl

Programmer
May 24, 2005
1,975
US
Hi All,
I am working on a VBS script to do automated cleanup of old files that are produced from one of our applications.

I am trying to figure out how to delete files that have their read only property set.

I use Scripting.FileSystemObject to access the drive, loop through all folders in the specified path and test each files last modified date and delete it if it is beyond a specified number of days old.
But if I run into a file set read only it just errors out on me. I have yet to test if files set hidden are an issue also.

Thoughts?

This is for our mainframe print system in the test environment. All test comes out in PDF files which company wide adds up to large amounts of data very quickly for all the different business units so it is important that we be able to automate cleanup of old files.

Thanks.

At my age I still learn something new every day, but I forget two others.
 
fso.DeleteFile filespec[!], True[/!]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
That got it thanks.
In my script it was:
objFile.Delete true

I knew there was a way to set it to force but I could not find anything on the command. All my searches came up with code that was creating a function called FileDelete or DeleteFile rather than the command itself.



At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top