0

In windows, the directories inside the C drive can be changed into writable manually by editing the security attributes of a directory providing full control to the user. How this can be done in Python?

My thinking was:

import os, stat
my_dir = 'C:\\Program Files\\Java'
os.chmod (my_dir, stat.S_IWRITE)

But no success.

Do anyone have idea?

Perlita
  • 1
  • 1
  • 2

1 Answers1

0

Try like this,

os.chmod(my_dir,0o777) # read and write by everyone
os.chmod(my_dir,0o755)  # read and write by me, readable for everone else

Python chmod documentation

Note Although Windows supports chmod(), you can only set the file’s read-only flag with it (via the stat.S_IWRITE and stat.S_IREAD constants or a corresponding integer value). All other bits are ignored.

Adem Öztaş
  • 20,457
  • 4
  • 34
  • 42