Friday, September 24, 2010

Read-only directory in Windows XP

Yesterday I had to make a read-only directory in Windows XP. Surprisingly this was the apparently the first time. As Windows has for a long time been marketed as easy to use, compared to e.g. Linux, because the user does not need to write cryptic commands on the command-line but use graphical tools I assumed this to be an easy task.
So, how to make a read-only directory/folder in Windows XP?

Well, not like this:


But like this (Using PowerShell as Command Prompt is not powerful enough):

$acl = get-acl .\readonlyDir
$rule=new-object System.Security.AccessControl.FileSystemAccessRule("MY-DESKTOP\username","CreateDirectories","Deny")
$acl.SetAccessRule($rule)
$rule=new-object System.Security.AccessControl.FileSystemAccessRule("MY-DESKTOP\username","CreateFiles","Deny")
$acl.AddAccessRule($rule)
set-acl .\readonlyDir $acl

Since I'm not a Windows expert my solution is probably not optimal so I gladly accept easier ways to make a read-only directory.

Monday, September 20, 2010

Monday, September 6, 2010