How to copy a file on Windows while preserving permissions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Koenig

    How to copy a file on Windows while preserving permissions

    The answer to this question probably involves pywin32 or a similar library.

    I would like to copy a file from one place to another on a Windows machine
    while preserving as much of the file permissions as it is possible to
    preserve with whatever my program's privileges happen to be. If the file is
    a directory (i.e. folder), this might require temporarily granting myself
    write permission for the directory so I can (recursively) create files in
    it--again, assuming that it is possible to do so.

    Obviously it would be necessary to determine whether my program's privileges
    are sufficient to solve this problem for the particular files in question.

    Can someone who is more familiar than I with the vagaries of Windows file
    protection and the Python interfaces available to it point me in a useful
    direction?


  • =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=

    #2
    Re: How to copy a file on Windows while preserving permissions

    Can someone who is more familiar than I with the vagaries of Windows file
    protection and the Python interfaces available to it point me in a useful
    direction?
    To copy a file along with its attributes, try SHFileOperation .

    Alternatively, if you have backup privileges, open the file for backup,
    then use BackupRead/BackupWrite.

    HTH,
    Martin

    Comment

    Working...