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?
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.
abhis_412
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.
abhis_412
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.
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.
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.
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).
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
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
2 Posts
Unable to copy files from current directory to Remote directory path(\\<Server_name>\<drive_name>...
May 29, 2019 10:37 AM|abhis_412|LINK
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:
Thanks in advance.
All-Star
53051 Points
23634 Posts
Re: Unable to copy files from current directory to Remote directory path(\\<Server_name>\<drive_n...
May 29, 2019 12:09 PM|mgebhard|LINK
An IIS application runs under application pool identity not the current user.
This is an access issue as the application pool does not have access to the network share.
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.
All-Star
48530 Points
18075 Posts
Re: Unable to copy files from current directory to Remote directory path(\\<Server_name>\<drive_n...
May 29, 2019 12:12 PM|PatriceSc|LINK
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.
None
0 Points
2 Posts
Re: Unable to copy files from current directory to Remote directory path(\\<Server_name>\<drive_n...
May 29, 2019 12:32 PM|abhis_412|LINK
Thank you! That was really helpful.
Contributor
3500 Points
1300 Posts
Re: Unable to copy files from current directory to Remote directory path(\\<Server_name>\<drive_n...
May 30, 2019 02:01 AM|Ackerly Xu|LINK
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
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.