I have a situation where I need to execute a .cmd program on my IIS website.
It's a 3rd party program to validate and transfer files, so I'm not able to choose otherwise.
I do this by starting the program in a new process programmatically.
Taking this approach with a .exe file works perfectly. I receive the standard output from the program. But this is just not the case when I try to do the same with the .cmd file. No standard output is received.
The code works perfectly on my local computer, so I figure that the problem lies within the IIS configuration. Probably user or file restrictions.
Could someone please guide me in the right direction?
EDIT Here is C# code I use.
ProcessStartInfo info = new ProcessStartInfo();
info.WindowStyle = ProcessWindowStyle.Hidden;
info.CreateNoWindow = true;
info.FileName = AppDomain.CurrentDomain.BaseDirectory + @"export\foo.cmd";
//replacing foo.cmd with foo.exe works
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
using (Process process = Process.Start(info))
{
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
Response.Write(result);
}
}
Best Answer
I found the solution myself. I have posted my findings on StackOverflow.
It actually turned out to be a IIS AppPool user issue, so posting the question here was not completely hopeless afterall.