Jared
Jared

Reputation: 6060

Allow IIS to Run a cmd command

Building an ASP.NET MVC3 application at work and I'm trying to use a program that has to be started through a command prompt and passed arguments.

Currently I'm getting...

System.ComponentModel.Win32Exception (0x80004005): Access is denied 
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) 
at System.Diagnostics.Process.Start() 
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)

This is only needed for one section of the website and I'm not sure what the best process would be to allow IIS (6) to accomplish this while maintaining security.

I don't think it's relevant, but just in case here is the code that I'm using to start the Process()

try {
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = @"C:\pdftohtml\pdftohtml.exe";
    startInfo.Arguments = "-c " + NewsletterPath + @"\" + fileName + ".pdf";

    Process.Start( startInfo );
} catch( Exception ex ) {
    return ex.ToString();
}

Question in a nutshell:

What is the best way to allow IIS6 to start a new Process that needs to pass arguments through a command prompt while maintaining security?

Upvotes: 3

Views: 10204

Answers (1)

Shai
Shai

Reputation: 25619

Grant access to the user running IIS (Usually ASPNET) to the directory c:\pdftohtml\, that'll fix it.

Upvotes: 5

Related Questions