title: How can I execute exe file (which writes a txt file) in classic asp
body: <p>I want to have a server page which executes a exe file compiled based on C</p>
  
  <p>the exe file is filew.exe generated by filew.c;</p>
  
  <p>filew.c></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main ()
  {
    FILE * fp;
    fp = fopen("test.txt" , "w");
    char* testStr = "this is test string";
    fwrite(testStr , 1 , sizeof(testStr) , fp);
    fclose(fp);
    return 0;
  }
  </code></pre>
  
  <p>I've tried few methods to accomplish this;</p>
  
  <p>first I tried to run with shellObject</p>
  
  <pre><code>Dim shellObj
  Set shellObj = Server.CreateObject("WScript.Shell")
  shellObj.run "E:\test\filew.exe"
  set shellObj = nothing
  </code></pre>
  
  <p>it didn't work.. so I tried this</p>
  
  <pre><code>Dim shellObj 
  shellObj = Server.CreateObject("Shell.Application")
  shellObj.ShellExecute "E:\test\filew.exe"
  Set shellObj = nothing
  </code></pre>
  
  <p>Still no... so I made a batch file that executes the exe file</p>
  
  <p>test.bat></p>
  
  <pre><code>dir &gt; e:\test\dir1.txt
  E:\test\filew.exe
  dir &gt; e:\test\dir2.txt
  </code></pre>
  
  <p>// the first and third line is to test whether the batch file is executed all right or not</p>
  
  <p>I called this batch file by</p>
  
  <pre><code>Dim shellObj
  Set shellObj = Server.CreateObject("WScript.Shell")
  shellObj.run "E:\test\test.bat"
  set shellObj = nothing
  </code></pre>
  
  <p>the result was... only dir1.txt and dir2.txt were created but no test.txt!!</p>