Using PHP to execute cmd commands

Wern Ancheta picture Wern Ancheta · Jun 26, 2012 · Viewed 44k times · Source

How do I properly execute commands in the command line using php? For example I'm using the command below in the command line to convert a docx file into a pdf file:

pdfcreator.exe /PF"D:\Documents\sample.docx

Now using PHP code I want to be able to execute the same command but nothing seems to be happening:

<?php
shell_exec('pdfcreator.exe /PF"D:\Documents\sample.docx"');
?>

Is this possible in PHP?If yes, how do I do it?

Answer

Piotr Olaszewski picture Piotr Olaszewski · Jun 26, 2012
system("c:\\path\\to\\pdfcreator.exe /PF\"D:\\Documents\\sample.docx""); 

try this.