Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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();
share|improve this question
Your question is unclear to me. Are you attempting to execute the CMD script as a CGI application? What do you mean, specifically, when you say "I do this by starting the program in a new process programmatically"? – Evan Anderson Jul 20 '12 at 12:11
I have tried 2 things. One is to start a new process with a pointer to the .cmd program. The other one is to start the cmd.exe program with a argument command pointer to the .cmd program. E.g. /c "path-to-file/foo.cmd". Wise people tell me these two approaches are exactly the same. – Marle1 Jul 20 '12 at 12:16
This question is probably a better fit for StackOverflow. – Ryan Bolger Jul 20 '12 at 14:10
I have actually posted a question on SO originally, since my first assumption was that the problem originated in the code. But being that the code works locally, I thought that the issue could relate to the IIS settings somehow. – Marle1 Jul 23 '12 at 7:11
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.