Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Windows 7 Forum Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How to remove read-only property of a file?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 08-02-2007   #1 (permalink)
dh
Guest


 

How to remove read-only property of a file?

When removing a file in ps, if the file is read-only, the command will fail.

Remove-Item c:\pstest\file1.txt

Is there a way to remove the "read-only" property of a file?

Thanks!

My System SpecsSystem Spec
Old 08-02-2007   #2 (permalink)
dreeschkind
Guest


 

RE: How to remove read-only property of a file?

You can use the good old console program attrib.exe to change file properties.
Run attrib /? to see how to use it.
Remove-Item also has a -force parameter to delete read-only files.

--
greetings
dreeschkind

"dh" wrote:

> When removing a file in ps, if the file is read-only, the command will fail.
>
> Remove-Item c:\pstest\file1.txt
>
> Is there a way to remove the "read-only" property of a file?
>
> Thanks!

My System SpecsSystem Spec
Old 08-02-2007   #3 (permalink)
Kiron
Guest


 

Re: How to remove read-only property of a file?

To view a file's attributes you can:

(Get-Item c:\pstest\file1.txt).attributes
ReadOnly, Archive

To change a file's attributes you can assign them to, or remove them from,
its attributes property:

(Get-Item c:\pstest\file1.txt).attributes = 'Archive'

Verify:

(Get-Item c:\pstest\file1.txt).attributes
Archive

But if you just want to delete the ReadOnly file use Remove-Item's -force
parameter, as dreeschkind suggested.

--
Kiron

My System SpecsSystem Spec
Old 08-02-2007   #4 (permalink)
David
Guest


 

RE: How to remove read-only property of a file?

This is what I have used

(Get-Childitem c:\pstest\file1.txt).Set_IsReadOnly($false)

"dh" wrote:

> When removing a file in ps, if the file is read-only, the command will fail.
>
> Remove-Item c:\pstest\file1.txt
>
> Is there a way to remove the "read-only" property of a file?
>
> Thanks!

My System SpecsSystem Spec
Old 08-02-2007   #5 (permalink)
Edengundam
Guest


 

Re: How to remove read-only property of a file?

use -force parameter.

"dh" <dh@discussions.microsoft.com> wrote:
news:7FB2BC20-CA0D-4D29-9CB9-32F11DDF6C50@microsoft.com...
> When removing a file in ps, if the file is read-only, the command will

fail.
>
> Remove-Item c:\pstest\file1.txt
>
> Is there a way to remove the "read-only" property of a file?
>
> Thanks!



My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Read-Only Checkbox in Folder Property window Peter K Vista General 3 06-16-2008 01:46 PM
Remove Read Only on a file in System folder Steve Vista security 1 06-15-2008 03:48 PM
Remove Member Property? Brian Vallelunga PowerShell 4 09-09-2007 08:23 PM
Read-only property won't turn off Michelle Vista General 2 07-06-2007 04:28 PM
Read zip files? Remove targeted file? clintonG PowerShell 2 04-13-2007 04:40 PM


Vistax64.com 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 2005-2008

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 47 48 49 50 51