Link to home
Start Free TrialLog in
Avatar of dowhatyoudo22

asked on

How to copy files and retain permissions of target folder

I need to create a process that will copy all .pdf files from one location (Windows Server 2003 directory) to another location (Windows Server 2008 R2) nightly. Once the files have been copied over I need them permissions of the target folder to be applied to them.

I tried to create a batch file that will be ran by Windows Scheduled Tasks nightly. The batch file simply copies the files from point A to point B. However the permissions of the target folder are not being applied. Because when I try to access any of the copied pdf files via a web application I have that views this directory I get an access denied error. If I simply go to the directory and refresh the permissions by taking them out and putting them back in for the account in question the error goes away.

Any suggestions?
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

robocopy source destination /sec
David is on point.

I generally use this syntax:

robocopy source destination /mir /sec /w:1 /r:1 /log: "log file location.txt"

robocopy \\servername\fileshare1 D:\foldername /mir /sec /w:1 /r:1 /log:"log location"

/mir = mirrors (exact copy)
/sec = copies security attributes
/w:1 = wait one sec before trying
/r:1 = retry once
Avatar of NVIT
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial