I have the following robocopy command to copy the directory from a folder on the network location to another folder on the same network location:

for /f %%a in ('wmic os get LocalDateTime ^| findstr ^[0-9]') do (set ts=%%a)
robocopy \\server\SharedFolder\ParentFolder\ChildFolder1 \\server\SharedFolder\ParentFolder\ChildFolder2 /log+:C:\Yash\log\log_%ts:~0,8%_%ts:~8,4%.log /e /xo /w:10 /r:2 /z /NP /TEE

I am calling this batch file from my ASP.Net MVC application. In debug mode everything is executing fine but when I deployed my application, it generates following log for robocopy:

ERROR 5 (0x00000005) Accessing Source Directory \server\SharedFolder\ParentFolder\ChildFolder1\ Access is denied.

May I know what permissions I need to set or any other way in which I can get this working. I simply want to copy folders, subfolders and files from one folder to another on the same network location.

Note: I have mapped \\server\SharedFolder on my machine

  • The thing to work out is "what user account is being used to access the file." This is usually the account that's running the web server service. Often this defaults to a local account on the server, which generally doesn't have network permissions. All of these are changeable. With the right configuration you can pass through the current user's credentials. Or you can tell IIS to run as a particular user, through the IIS management console. First thing I'd try is to tell IIS to run with my credentials. If that works, talk to domain admin for a service account.
    – GregHNZ
    Jul 25 '16 at 9:31
  • @GregHNZ Under Authentication option of the IIS, I clicked on ASP.Net Impersonation and edited its setting to authenticate specific user (admin since I a logged in as admin) credentials, but still it is showing the same error. I also tried giving Full control to the following roles "Network Service", "IUSR", "IIS_IUSRS". Still this didn't worked Jul 25 '16 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.