告诉PHP执行Windows命令但不等待响应

时间:2018-06-15 08:07:51

标签: php batch-file exec

在这里阅读了相关问题后,我尝试了各种解决方案,但没有一个正在运作。

我有一个.html文件的文件夹,用wkhtmltopdf转换为.pdf文件。 我有以下批处理文件,它可以完美地运行

FOR %%i IN ("c:\websites\chronologicalLogs\*.html") DO C:\websites\staffzone\wkhtmltopdf\bin\wkhtmltopdf.exe --margin-top 7 --margin-bottom 7 --margin-left 7 --margin-right 7  --load-error-handling ignore %%i "c:\websites\chronologicalLogs\completed\%%~ni.pdf" &del %%i
exit

然而,在我的html文件创建之后,我已经尝试了几种方法从php文件执行它,但它总是等待响应...我不想要。

我试过了 1)

$cmd="C:\\websites\\eyfs\\createPDFLogs.bat";
exec($cmd);

这会启动批处理文件,但是等待回复...没有好处。

2)

pclose(popen("start /B " . $cmd, "r"));

这似乎没有启动批处理文件

3)

exec('start /B C:\websites\eyfs\createPDFLogs.bat'); 

再次,这也不会启动批处理文件。

我知道这个:

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($cmd, 0, false);

但我没有权限在php.ini

中启用此功能

你能想到什么吗?

由于

0 个答案:

没有答案