title: how to execute win cmd from php code?
body: <p>I have x.exe in this path: <code>C:\inetpub\wwwroot\webclient\db\nucleotide</code> and I want to execute this command: <code>blastdbcmd -db nr -entry all -outfmt "%g %T"</code>.</p>
  
  <p>In Windows command line I do:</p>
  
  <pre><code>cd C:\inetpub\wwwroot\webclient\db\nucleotide
  blastdbcmd -db nr -entry all -outfmt "%g %T"
  </code></pre>
  
  <p>How can I do this from php code. I know <code>exec($cmd)</code> or <code>shell_exec($cmd)</code> will do it but, how to type the above two statement in <code>$cmd</code>?</p>
  
  <p><strong>Edit1:</strong>
  How to save the output of the command in a text file?
  I try 3 statement:</p>
  
  <pre><code>chdir("C:\\inetpub\\wwwroot\\webclient\\db\\nucleotide");
  $cmd = "blastdbcmd.exe -db nr -entry all -outfmt "%g %T" -out $text_files_path/NewSeq_$OldDatabaseFile$NewDatabaseFile.txt";
  exec($cmd);
  </code></pre>
  
  <p>,,</p>
  
  <pre><code>exec("C:\inetpub\wwwroot\webclient\db\nucleotide\blastdbcmd.exe -db nr -entry all -outfmt "%g %T" -out $text_files_path/NewSeq_$OldDatabaseFile$NewDatabaseFile.txt");
  </code></pre>
  
  <p>,,</p>
  
  <pre><code>exec("cd C:\inetpub\wwwroot\webclient\db\nucleotide &amp;&amp; blastdbcmd.exe -db nr -entry all -outfmt \"%g %T\" -out $text_files_path/NewSeq_$OldDatabaseFile$NewDatabaseFile.txt");
  </code></pre>
  
  <p>but, NewSeq_$OldDatabaseFile$NewDatabaseFile.txt not generated. It seems that the command not executed!</p>
  
  <p>What can I do?</p>
  
  <p>Thanks.</p>