set file permission on windows

Mike Driscoll kyosohma at gmail.com
Tue Apr 8 13:33:40 EDT 2008


On Apr 8, 12:03 pm, "Tim Arnold" <tim.arn... at sas.com> wrote:
> hi, I need to set file permissions on some directory trees in windows using
> Python.
>
> When I click on properties for a file and select the 'Security' tab, I see a
> list of known 'Group or user names' with permissions for each entry such as
> Full Control, Modify, Read&Execute,  etc.
>
> I need to (for example) periodically set Group Permissions for one group to
> Read, and another Group to None. I need to apply the settings to several
> directory trees recursively.
>
> If this was on Unix, I'd just use os.stat I guess. I don't think that will
> work in this case since all I know is the Group names and the permissions I
> need to allow.
>
> thanks for any pointers,
> --Tim Arnold

According to the following thread, you can use os.chmod on Windows:

http://mail.python.org/pipermail/python-list/2003-June/210268.html

You can also do it with the PyWin32 package. Tim Golden talks about
one way to do it here:

http://timgolden.me.uk/python/win32_how_do_i/add-security-to-a-file.html

Also see the following thread:

http://mail.python.org/pipermail/python-win32/2004-July/002102.html

or

http://bytes.com/forum/thread560518.html

Hope that helps!

Mike



More information about the Python-list mailing list