更新时间:2023-02-22 14:36:42
PHP手册的相关部分有一些帖子,例如这一个:
There are a few posts to the relevant sections of the PHP Manual such as this one:
我无法使用PHP exec命令执行任何批处理
文件。执行其他命令(即dir)工作正常。但是如果我
执行了一个批处理文件,我收到了exec命令的输出。
I was having trouble using the PHP exec command to execute any batch file. Executing other commands (i.e., "dir") works fine). But if I executed a batch file, I receieved no output from the exec command.
我的服务器设置包括运行
IIS6和PHP 5.2.3的Windows Server 2003服务器。在这台服务器上,我有:
The server setup I have consists of Windows Server 2003 server running IIS6 and PHP 5.2.3. On this server, I have:
事实证明,即使在服务器上安装了以上所有内容,我也是如此b $ b必须在exec调用中指定cmd.exe的完整路径。
It turns out that even with all of the above in place on the server, I had to specify the full path to cmd.exe in the exec call.
当我使用调用时: $ output = exec( C:\\windows\\system32\\cmd.exe
/ c $ batchFileToRun);
然后一切正常。在我的情况下, $ batchFileToRun
是批处理文件的
实际系统路径(即调用
realpath()的结果)。
then everything worked fine. In my situation, $batchFileToRun
was the
actual system path to the batch file (i.e., the result of a call to
realpath()).
exec
和 shell_exec
手册页。也许通过它们可以得到它并为你工作。
There are a few more on both the exec
and shell_exec
manual pages. Perhaps following through them will get it up and working for you.