【Python学习】将目录的最高权限给每一个用户

 1 import os
 2 def release(obj=r'C:\ProgramData\test'):
 3    try:
 4         if os.path.isfile(obj):
 5             return
 6         cmd = 'cacls ' + obj + '\*.* /g everyone:f'
 7         print(cmd)
 8         # os.system(cmd)
 9         p = os.popen(cmd, "w")  # auto confirm
10         p.write('y\n')
11         subobjs = os.path.os.listdir(obj)
12         if subobjs == []:
13             return
14         else:
15             for temp in subobjs:
16                 tempobj = os.path.join(obj, temp)
17                 release(tempobj)
18    except Exception as e:
19         print(e)

 

posted @ 2020-04-10 15:25  gtea  阅读(272)  评论(0编辑  收藏  举报