使用PHP执行cmd命令 [英] Using PHP to execute cmd commands

查看:137
本文介绍了使用PHP执行cmd命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用php在命令行中正确执行命令?例如,我在命令行中使用以下命令将docx文件转换为pdf文件:

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

现在使用PHP代码,我希望能够执行相同的命令,但似乎什么也没发生:

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"');
?>

这在PHP中可行吗?如果可以,我该怎么办?

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

推荐答案

system("c:\\path\\to\\pdfcreator.exe /PF\"D:\\Documents\\sample.docx""); 

尝试一下.

这篇关于使用PHP执行cmd命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆