title: Is it possible to run a batch file as a cgi in apache under windows?
body: <p>This sounds incredibly simple to do, but I can't make it work. I have it working with awk and perl, but cmd.exe wasn't designed to be a cgi program so no matter what I do, I either get the browser downloading the file, internal server error, or I get the path of the current directory as the first line.</p>
  
  <p>You HAVE to put a #! in the first line of a cgi, or you get an internal server error, but I end up with</p>
  
  <pre><code>C:\Program Files (x86)\Apache Software Foundation\Apache2.2\cgi-bin&gt;#!c:\windows\system32\cmd.exe /c
  Content-Type: text/html
  
  &lt;HTML&gt;&lt;BODY&gt;
  &lt;PRE&gt;Your environment variables are:
  &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;
  </code></pre>
  
  <p>I've tried with /c, without, any number of permutations, it always prints the current working directory first before anything, so I can't print out the content type as a header.</p>
  
  <p>Anybody ever get this working? I see lots of speculation in the results google shows me, but no actual working examples.</p>