set file permission on windows

T

Tim Arnold

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
 
M

Mike Driscoll

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
 
T

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

Hi Mike,
It does help indeed, especially the last two links. That certainly gets me
started in the right direction. I'm always amazed at the helpful generosity
of the folks on this list.
thanks again for the help.
--Tim Arnold
 
M

Mike Driscoll

Hi Mike,
It does help indeed, especially the last two links. That certainly gets me
started in the right direction. I'm always amazed at the helpful generosity
of the folks on this list.
thanks again for the help.
--Tim Arnold

Hi Tim,

I thought I'd used the methods in those last two links before, but I
was thinking of changing permissions on running services to reboot a
PC, which is not quite the same. If you run into more issues, there's
a PyWin32 mailing list with helpful people there too. You can find it
here: http://mail.python.org/mailman/listinfo/python-win32

Mike
 
T

Tim Golden

Tim said:
Hi Mike,
It does help indeed, especially the last two links.

Hi, Tim. For the purposes of improving that page of mine linked
above, would you mind highlighting what made it less useful
than the last two links? On the surface, it seems to match your
use case pretty closely. Was there too much information? Too
little? Poor formatting? Just didn't feel right? I've a small set
of security-related pages in train and I'd rather produce something
which people find useful.

Thanks

TJG
 
T

Tim Arnold

Tim Golden said:
Hi, Tim. For the purposes of improving that page of mine linked
above, would you mind highlighting what made it less useful
than the last two links? On the surface, it seems to match your
use case pretty closely. Was there too much information? Too
little? Poor formatting? Just didn't feel right? I've a small set
of security-related pages in train and I'd rather produce something which
people find useful.

Thanks

TJG

Hi TJG. Thanks for the site. Unfortunately, I mis-typed in the previous
reply and that should have been the 'first two links' instead of 'last two
links'. In fact I bookmarked your site so I can re-read the material and I
copied the code to play around with. Excellent example--it contains just
what I needed to know, esp. since it replaces the dacl instead of modifying
one. Now I can remove access for 'Everybody' by simply not including it in
the new dacl.

thanks!
--Tim Arnold
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top