php批处理并返回到php

php批处理并返回到php,php,windows,batch-file,Php,Windows,Batch File,以下批处理代码(文件名为autoFTP.bat)将重命名文件夹中的文件: @echo off setlocal EnableDelayedExpansion ::---------- Path to files that must be renamed for /f "delims=" %%i in ('dir /b D:\folder\*.htm') do ( ::---------- Path to md5sums.exe for /f "skip=3 delims=" %%j in ('m

以下批处理代码(文件名为
autoFTP.bat
)将重命名文件夹中的文件:

@echo off
setlocal EnableDelayedExpansion
::---------- Path to files that must be renamed
for /f "delims=" %%i in ('dir /b D:\folder\*.htm') do (
::---------- Path to md5sums.exe
for /f "skip=3 delims=" %%j in ('md5sums -n -b "%%i"') do (
set number=%%i
set file=%%j
set file=!file:*.htm=!
for %%k in (!file!) do (
ren "%%i" "%%k.htm"
echo "!number! %%k"
)
)
)
echo.
update.php
中,我想运行批处理文件并在php文件中获得结果(文件的旧名称和新名称)。
update.php
包含:

$fileName = exec("cmd /c D:\folder\autoFTP.bat", $out);

foreach($out as $line) {
    echo $line;
}
我在php手册中读到,
$out
应该是一个结果数组,但是
$line
是空的

理论上,我想在DB中更新重命名文件的名称(不是文件,只是重命名文件的名称)。因此,为了做到这一点,我希望
$out
变量包含文件的原始名称以及重命名的名称

如果我独立于cmd运行
autoFTP.bat
,它将正常工作;但是当我试着从
update.php
调用它时,它什么也不做


我做错了什么,但我不知道是什么。

确定它运行bat文件吗?如果出现错误,请尝试捕捉并检查。检查日志。请记住,您正试图在用户运行apache进程的情况下运行bat文件。