Avatar of dowhatyoudo22
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?
Windows OSFile Sharing Software

Avatar of undefined
Last Comment
NVIT

8/22/2022 - Mon
David Johnson, CD

robocopy source destination /sec
Raymond Peng

David is on point.

I generally use this syntax:

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

sample:
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

https://technet.microsoft.com/en-us/library/Cc733145.aspx?f=255&MSPPError=-2147217396
ASKER CERTIFIED SOLUTION
NVIT

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy