By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,035 Members | 1,384 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,035 IT Pros & Developers. It's quick & easy.

set file permission on windows

P: n/a
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
Apr 8 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Apr 8, 12:03 pm, "Tim Arnold" <tim.arn...@sas.comwrote:
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/pyt...ne/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_...to-a-file.html

Also see the following thread:

http://mail.python.org/pipermail/pyt...ly/002102.html

or

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

Hope that helps!

Mike
Apr 8 '08 #2

P: n/a
"Mike Driscoll" <ky******@gmail.comwrote in message
news:7d**********************************@m44g2000 hsc.googlegroups.com...
On Apr 8, 12:03 pm, "Tim Arnold" <tim.arn...@sas.comwrote:
> <snip>
According to the following thread, you can use os.chmod on Windows:

http://mail.python.org/pipermail/pyt...ne/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_...to-a-file.html

Also see the following thread:

http://mail.python.org/pipermail/pyt...ly/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
Apr 8 '08 #3

P: n/a
On Apr 8, 1:19 pm, "Tim Arnold" <tim.arn...@sas.comwrote:
"Mike Driscoll" <kyoso...@gmail.comwrote in message

news:7d**********************************@m44g2000 hsc.googlegroups.com...
On Apr 8, 12:03 pm, "Tim Arnold" <tim.arn...@sas.comwrote:
<snip>
According to the following thread, you can use os.chmod on Windows:
http://mail.python.org/pipermail/pyt...ne/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_...to-a-file.html
Also see the following thread:
http://mail.python.org/pipermail/pyt...ly/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
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
Apr 8 '08 #4

P: n/a
Tim Arnold wrote:
"Mike Driscoll" <ky******@gmail.comwrote in message
news:7d**********************************@m44g2000 hsc.googlegroups.com...
>On Apr 8, 12:03 pm, "Tim Arnold" <tim.arn...@sas.comwrote:
>> <snip>
>According to the following thread, you can use os.chmod on Windows:

http://mail.python.org/pipermail/pyt...ne/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_...to-a-file.html

Also see the following thread:

http://mail.python.org/pipermail/pyt...ly/002102.html

or

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

Hope that helps!

Mike

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
Apr 8 '08 #5

P: n/a
"Tim Golden" <ma**@timgolden.me.ukwrote in message
news:ma*************************************@pytho n.org...
Tim Arnold wrote:
>"Mike Driscoll" <ky******@gmail.comwrote in message
news:7d**********************************@m44g200 0hsc.googlegroups.com...
>>On Apr 8, 12:03 pm, "Tim Arnold" <tim.arn...@sas.comwrote:
<snip>
>>According to the following thread, you can use os.chmod on Windows:

http://mail.python.org/pipermail/pyt...ne/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_...to-a-file.html

Also see the following thread:

http://mail.python.org/pipermail/pyt...ly/002102.html

or

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

Hope that helps!

Mike

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
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
Apr 9 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.