Here’s a fast PowerShell tip. Need to mark a file as Read-Only? Use Get-ChildItem to get the file and then invoke the Set_IsReadOnly method. This method needs a Boolean value (True or False) to indicate whether a file is ReadOnly.
(Get-ChildItem e:\files\protected.txt).Set_IsReadOnly($True)
That’s all there is to it. If you want to check if the file is readonly:
(Get-ChildItem e:\files\protected.txt).IsReadOnly
Will display True or False.
You could also use the set_Attributes method, but be sure to include all the current attributes if you are trying to add ReadOnly. Otherwise set_Attributes will erase the old attributes and use whatever you assign.
I am new to VB script and it would be so good if i get your help in coding. I am a tester and i am in automation testing, so i need to know vb script. Please let me know your response on this!!
James.
I encourage you to visit ScriptingAnswers.com. It is a free community site devoted to administrative scripting, although you do have to register. There are discussion forums, a script vault and much more.