Executing batch file from C# Permission issue Executing batch file from C# Permission issue asp.net asp.net

Executing batch file from C# Permission issue


For this to work your app pool needs to be run as a user who has access to the batch file. Check how to change your app pool identity for IIS 7 or IIS 6.


To expand on what Kartheek said:

  • In IIS 7 application pools run as a app pool account, IISAPPPOOL\AppPoolName
  • In IIS 6 application pools run as Network Service
  • In either case, these accounts don't have any access a user's documents folder and (by default) can only read from common data stores.

Generally you want to keep the app pool account because it helps segregate the data -- so what I would do is just make sure you grant read+execute permissions on the bat file you need for the app pool account. You'll also need proper permissions on any filles/folders the bat needs to read/write from.

You do not need to change anything in your app to correct this problem, unless you want to IIS app to masquerade around as the user who is actually sitting at the website (it only really works if you use some form of authentication.) Generally this a bad idea anyway -- so it's best to just adjust the permissions.

As a general rule of thumb, when working on a web server you want to keep the permissions/execution levels as low/restrictive as possible.