locked
Unable to copy files from current directory to Remote directory path(\\<Server_name>\<drive_name>$\<Folder_path>) RRS feed

  • Question

  • User-1280395480 posted

    I have an application hosted in IIS server and it executes a batch file. The batch file contains few CMD command such as mkdir, xcopy etc. When I run the same application from Visual Studio, it copies all the files inside the new folder successfully. When I try to run the same application from IIS, it ends without throwing any error. The authentication used in the application is Windows and it is configured inside config file.

    So, below are the point of concerns:

    • While running the application, which user helps to authenticate the folder access, is that IIS user or the current user?
    • Is that access related issue or any other configuration related?
    • What is the preferable solution?

    Thanks in advance.

    Wednesday, May 29, 2019 10:37 AM

All replies

  • User475983607 posted

    While running the application, which user helps to authenticate the folder access, is that IIS user or the current user?

    An IIS application runs under application pool identity not the current user. 

    Is that access related issue or any other configuration related?

    This is an access issue as the application pool does not have access to the network share.

    What is the preferable solution?

    The solution depends on your requirements.  I generally set the application pool identity to a service account.  Then grant access rights to the service account.

    Wednesday, May 29, 2019 12:09 PM
  • User753101303 posted

    Hi,

    Likely a permission problem. AFAIK \\server\drive$ is only available to admin accounts. It would be likely better to create your own share with the needed permissions rather than trying to access a full drive.

    More likely you could see an error if redirecting the batch file output to a trace file.

    Wednesday, May 29, 2019 12:12 PM
  • User-1280395480 posted

    Thank you! That was really helpful.

    Wednesday, May 29, 2019 12:32 PM
  • User-893317190 posted

    Hi abhis_412,

    You could change the application pool's identity to local system to check whether it is a permission problem, because local system has similar permission as administrator.

    About how to change application pool's identity to local system, you could refer to https://docs.microsoft.com/en-us/iis/manage/configuring-security/application-pool-identities

    If  after you have changed to local system , the problem is solved, the problem may have something to do with permission.

    Then you could add  permission of all the related folder to your application pool user and reset your application pool's identity to ApplicationPoolIdentity( give  application pool too mush permission is not suitable).

    About application pool  and file system's permission  and how to change the permission, please refer to https://stackoverflow.com/questions/5437723/iis-apppoolidentity-and-file-system-write-access-permissions

    In addition, from your title, you are going to copy files to remote directory,  please ensure your iis server has network connection to remote server.

    Best regard,

    Ackerly Xu

    Thursday, May 30, 2019 2:01 AM