Click here to Skip to main content
15,882,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I have a hidden folder at my C:\.

I want to change the folder attribute to ReadOnly.

Please help me on this.

What I have tried:

Set-ItemProperty -Path "$Directory_Path$Directory" -Name attributes -Value ((Get-ItemProperty "$Directory_Path$Directory").attributes -bxor ([io.fileattributes]::Normal))
Posted
Updated 26-May-16 1:56am
Comments
Richard MacCutchan 26-May-16 7:41am    
What is the problem?
Black_Rose 26-May-16 7:52am    
Problem is it's not changing anything.It's executing without any error.
Sergey Alexandrovich Kryukov 26-May-16 11:06am    
I want to warn you, just in case: this attribute won't really protect anything, any piece of software can override it, and will, hopefully, on the user consent.
—SA

1 solution

 
Share this answer
 
Comments
Black_Rose 26-May-16 22:53pm    
Sir, I am not able to figure it out how the given link is relating my issue. can you please explain this.
Richard MacCutchan 27-May-16 3:09am    
Go to the link, study all the samples. They show you how to add more code to help diagnose what is happening in your script. We cannot see the value of all the variables in your code, or the status and attributes of any files that are referenced.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900