Error running a command line .exe from asp.net
<p>I have a command line program which runs fine from the DOS window interactively. When I try to execute the same command and arguments from within an asp.net app, it fails. The web app has Script &amp; Execute permissions. For testing purposes, I gave full control permissions to the Everyone group for the whole web app folder and for the folder containing the .exe file (resides in Program Files). The web app is using Windows integrated security (no anonymous) so it should use my credentials and I am an admin. Running in WIndows XP.</p>

<p>The code below runs the command. The filename and arguments look good. However the p.ExitCode =1 instead of 0. How do I troubleshoot and find out why the process is failing? I looked at the process in the debugger and I see some 'System.InvalidOperationException' exceptions but that doesn't tell me much. Why InvalidOperationException?</p>

<pre><code>Process p = new Process();
            p.StartInfo.FileName = filename;
            p.StartInfo.Arguments = arguments;
            p.StartInfo.CreateNoWindow = true;
            p.StartInfo.UseShellExecute = true;           
            p.StartInfo.RedirectStandardOutput = false;
            p.StartInfo.RedirectStandardError = false;
            p.Start();
            p.WaitForExit();
            if (0 != p.ExitCode)
            {
                ApplicationException ex =
                    new ApplicationException(string.Format("\"{0} {1}\" returned ({2})", filename, arguments, p.ExitCode));
                throw ex;
        }
</code></pre>
