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?
dowhatyoudo22Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
robocopy source destination /sec
0
Raymond PengSystems EngineerCommented:
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
0
NVITCommented:
> ...the permissions of the target folder are not being applied
Clarification: You want the permissions of the target, not the source permissions, to be applied. Correct? If so...

A plain robocopy w/o switches just copies files w/o permissions. i.e. robocopy \\server2003\share \\server2008\share "*.pdf". The permissions at the target are based on those of the target parent folder. You are probably using one or more of the security switches, e.g. /sec, /copyall, which copies the source permissions.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.