Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Give IIS permissions to run as administrator (in order to run from web .exe that write to folders)

Tags:

asp.net

iis

I have an API in mvc4 that call to .exe file via 'Process' class.
This .exe using log4net, and run another .exe that export files to directory and subdirectories. In the end of the process, the .exe post to http API.

Process p = new Process();
p.StartInfo.FileName = ConfigurationManager.AppSettings["ExtractToolPath"];
p.StartInfo.Arguments = this.strcommand;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.Verb = "runas";
p.StartInfo.RedirectStandardInput = true;
p.Start();
string s = p.StandardOutput.ReadToEnd();
p.WaitForExit();

String 's' returns with "" (blank string).

The s paramter get what was printed to the Console window. And I did a print in the begining of the .exe, therefor I know it even not started the process.

Important: When I remove the log4net logger, the 's' parameters gets some output, but it's failes when tring to do any command that requieres write permissions.

I tried to give the IIS executable permission, and immpersonation with admin username and password. I did my directories 'share' to everyone. Nothing helped.

like image 884
Megi Ben Nun Avatar asked Jan 13 '13 09:01

Megi Ben Nun


Video Answer


1 Answers

Did you try setting the application pool identity to an administrator? Or giving write permissions on the directory to the application pool identity?

The credentials used to do the writing are the ones in the application pool identity.

like image 125
Elad Lachmi Avatar answered Oct 14 '22 05:10

Elad Lachmi