473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

set file permission on windows

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
5 12713
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
"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has...
11
by: sur | last post by:
Hello, My problem is that File.Exists works fine if my file is on my local drive but returns false if its on any other drive. I think that the issue is probably file permissions and so I have...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
15
by: David Thielen | last post by:
Hi; My ASP.NET app (C# calling J# under .net 2.0) creates a png file in a subdirectory to display as part of the created page. However, the bitmap will not display due to a security violation. ...
2
by: jdlists | last post by:
I'm running python on windows and have a program that watches a directory and acts on files as they come into the directory. After processing is complete, i delete the file, or in this case...
4
by: klynn | last post by:
Hi: I'm having problems reading a Microsoft Access file from my ASP.Net app on a Windows Server 2003 machine. The error message: The Microsoft database engine cannot open the file, <my_file>. It...
10
by: John Salerno | last post by:
I always read about how you need to set certain file permissions (for cgi files, for example), but it's never been clear to me *how* you do this. I know you can run the line chmod 755...
0
by: dphill | last post by:
Hello all I am a beginner .Net programmer so please forgive my ignorance. In brief, I am trying to read from xml file stored in a SQL database table’s field. This is what I used to create...
16
by: Mich | last post by:
Hi, i'm building an web application for anonymous users. They can take a look in the website, nothing more. In order to perform other actions, the anonymous user must be logged. So i create an...
3
by: unauthorized | last post by:
I'm running a PHP 5.1 on an Apache 2.2 server under Windows XP which I use to develop my web apps. Currently, I am trying to add "upload" functionality to my project, but for some reason, when the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.