Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > set file permission on windows

Reply
Thread Tools

set file permission on windows

 
 
Tim Arnold
Guest
Posts: n/a
 
      04-08-2008
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


 
Reply With Quote
 
 
 
 
Mike Driscoll
Guest
Posts: n/a
 
      04-08-2008
On Apr 8, 12:03 pm, "Tim Arnold" <(E-Mail Removed)> 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/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
 
Reply With Quote
 
 
 
 
Tim Arnold
Guest
Posts: n/a
 
      04-08-2008
"Mike Driscoll" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Apr 8, 12:03 pm, "Tim Arnold" <(E-Mail Removed)> wrote:
>> <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


 
Reply With Quote
 
Mike Driscoll
Guest
Posts: n/a
 
      04-08-2008
On Apr 8, 1:19 pm, "Tim Arnold" <(E-Mail Removed)> wrote:
> "Mike Driscoll" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > On Apr 8, 12:03 pm, "Tim Arnold" <(E-Mail Removed)> wrote:
> >> <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
 
Reply With Quote
 
Tim Golden
Guest
Posts: n/a
 
      04-08-2008
Tim Arnold wrote:
> "Mike Driscoll" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> On Apr 8, 12:03 pm, "Tim Arnold" <(E-Mail Removed)> wrote:
>>> <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
 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      04-09-2008
En Tue, 08 Apr 2008 14:03:06 -0300, Tim Arnold <(E-Mail Removed)>
escribió:

> hi, I need to set file permissions on some directory trees in windows
> using
> Python.


The hard way: Use the function SetFileSecurity, the pywin32 package
exposes it. See the Microsoft documentation at
http://msdn2.microsoft.com/en-us/lib...60(VS.85).aspx

The easy way: the cacls command

--
Gabriel Genellina

 
Reply With Quote
 
Tim Arnold
Guest
Posts: n/a
 
      04-09-2008
"Tim Golden" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Tim Arnold wrote:
>> "Mike Driscoll" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> On Apr 8, 12:03 pm, "Tim Arnold" <(E-Mail Removed)> wrote:
>>>> <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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fixed: The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID {555F3418-D99E-4E51-800A-6E89CFD8B1D7} to the user NT AUTHORITY\LOCAL SERVICE SID (S-1-5-19). Skybuck Flying Windows 64bit 1 06-29-2009 06:17 PM
PERL windows : "Windows cannot access the specified device, path orfile. You may not have the appropriate permission to access the item." guru Perl Misc 4 02-18-2009 04:46 PM
Set File/User Permission with ASP/VBScript to a File david.didonato@gmail.com ASP General 1 07-27-2007 02:56 PM
saving file permission denied on windows zombek@gmail.com Python 4 05-16-2006 01:59 PM
How to set permission to write to an xml file JRV ASP .Net 2 12-10-2003 04:04 AM



Advertisments