Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 267
Jared Avatar asked Apr 20 '26 09:04

Jared


1 Answers

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

like image 79
Shai Avatar answered Apr 24 '26 01:04

Shai



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!