Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Unable to delete a read only file

Reply
 
Old 07-23-2009   #1 (permalink)
Jason


 
 

Unable to delete a read only file

Hello

I'm logged in as local admin, and i'm trying to delete a file that is marked
Read Only

If (fso.FileExists("C:\afdxcfg.bin")) Then
Set MyFile = fso.GetFile("C:\filename.bin")
Myfile.Delete
End If

For some reason I still get a access denied error.

Any ideas



My System SpecsSystem Spec
Old 07-23-2009   #2 (permalink)
Tom Lavedas


 
 

Re: Unable to delete a read only file

On Jul 23, 4:32*pm, "Jason" <nos...@xxxxxx> wrote:
Quote:

> Hello
>
> I'm logged in as local admin, and i'm trying to delete a file that is marked
> Read Only
>
> *If (fso.FileExists("C:\afdxcfg.bin")) Then
> * * Set MyFile = fso.GetFile("C:\filename.bin")
> * * Myfile.Delete
> * End If
>
> For some reason I still get a access denied error.
>
> Any ideas
Have you tried doing the obvious? - That is resetting the attributes
to remove the read-only status, as in ...

If (fso.FileExists("C:\afdxcfg.bin")) Then
Set MyFile = fso.GetFile("C:\filename.bin")
Myfile.Attribute = 0 ' resets all attributes to off
Myfile.Delete
End If

Tom Lavedas
***********
My System SpecsSystem Spec
Old 07-23-2009   #3 (permalink)
Tom Lavedas


 
 

Re: Unable to delete a read only file

On Jul 23, 4:40*pm, Tom Lavedas <tglba...@xxxxxx> wrote:
Quote:

> On Jul 23, 4:32*pm, "Jason" <nos...@xxxxxx> wrote:
>
Quote:

> > Hello
>
Quote:

> > I'm logged in as local admin, and i'm trying to delete a file that is marked
> > Read Only
>
Quote:

> > *If (fso.FileExists("C:\afdxcfg.bin")) Then
> > * * Set MyFile = fso.GetFile("C:\filename.bin")
> > * * Myfile.Delete
> > * End If
>
Quote:

> > For some reason I still get a access denied error.
>
Quote:

> > Any ideas
>
> Have you tried doing the obvious? - That is resetting the attributes
> to remove the read-only status, as in ...
>
> *If (fso.FileExists("C:\afdxcfg.bin")) Then
> * * Set MyFile = fso.GetFile("C:\filename.bin")
> * * Myfile.Attribute = 0 ' resets all attributes to off
> * * Myfile.Delete
> * End If
>
> Tom Lavedas
> ***********
Sorry, there's a typo - it should be Myfiles.AttributeS (with an S).

Tom Lavedas
***********
My System SpecsSystem Spec
Old 07-23-2009   #4 (permalink)
Jason


 
 

Re: Unable to delete a read only file

Thanks, got it.


"Tom Lavedas" <tglbatch@xxxxxx> wrote in message
news:bc0effaf-d9b8-4472-9377-12810bc73184@xxxxxx
On Jul 23, 4:40 pm, Tom Lavedas <tglba...@xxxxxx> wrote:
Quote:

> On Jul 23, 4:32 pm, "Jason" <nos...@xxxxxx> wrote:
>
Quote:

> > Hello
>
Quote:

> > I'm logged in as local admin, and i'm trying to delete a file that is
> > marked
> > Read Only
>
Quote:

> > If (fso.FileExists("C:\afdxcfg.bin")) Then
> > Set MyFile = fso.GetFile("C:\filename.bin")
> > Myfile.Delete
> > End If
>
Quote:

> > For some reason I still get a access denied error.
>
Quote:

> > Any ideas
>
> Have you tried doing the obvious? - That is resetting the attributes
> to remove the read-only status, as in ...
>
> If (fso.FileExists("C:\afdxcfg.bin")) Then
> Set MyFile = fso.GetFile("C:\filename.bin")
> Myfile.Attribute = 0 ' resets all attributes to off
> Myfile.Delete
> End If
>
> Tom Lavedas
> ***********
Sorry, there's a typo - it should be Myfiles.AttributeS (with an S).

Tom Lavedas
***********


My System SpecsSystem Spec
Old 07-23-2009   #5 (permalink)
mayayana


 
 

Re: Unable to delete a read only file

Another even more obvious option:

FSO.DeleteFile "C:\File.txt", True

Quote:

> Hello
>
> I'm logged in as local admin, and i'm trying to delete a file that is
marked
Quote:

> Read Only
>
> If (fso.FileExists("C:\afdxcfg.bin")) Then
> Set MyFile = fso.GetFile("C:\filename.bin")
> Myfile.Delete
> End If
>
> For some reason I still get a access denied error.
>
> Any ideas
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Batch Commands To Read and Delete Lines from txt-File PowerShell
Unable to read / move / delete file with admin rights Vista file management
Unable to read or Delete Mail Vista mail
Backup - unable to read file or directory Vista General
Unable to delete unread messages that have been read Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46