Php Zend Framework-zf.bat文件生成命令行错误

Php Zend Framework-zf.bat文件生成命令行错误,php,zend-framework,command-line,batch-file,Php,Zend Framework,Command Line,Batch File,我根据需要修改了zf.bat文件的代码,但它会生成此错误 发生错误!操作“*”不是所有命令上的有效操作, 我怎样才能解决这个问题?。 以下是批处理文件的代码: @ECHO off REM Zend Framework REM REM LICENSE REM REM This source file is subject to the new BSD license that is bundled REM with this package in the file LICENSE.txt. REM

我根据需要修改了zf.bat文件的代码,但它会生成此错误 发生错误!操作“*”不是所有命令上的有效操作, 我怎样才能解决这个问题?。 以下是批处理文件的代码:

@ECHO off
REM Zend Framework
REM
REM LICENSE
REM
REM This source file is subject to the new BSD license that is bundled
REM with this package in the file LICENSE.txt.
REM It is also available through the world-wide-web at this URL:
REM http://framework.zend.com/license/new-bsd
REM If you did not receive a copy of the license and are unable to
REM obtain it through the world-wide-web, please send an email
REM to license@zend.com so we can send you a copy immediately.
REM
REM Zend
REM Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
REM http://framework.zend.com/license/new-bsd     New BSD License


REM Test to see if this was installed via pear
SET ZTMPZTMPZTMPZ=@ph
SET TMPZTMPZTMP=%ZTMPZTMPZTMPZ%p_bin@
REM below @php_bin@
FOR %%x IN ("@php_bin@") DO (if %%x=="%TMPZTMPZTMP%" GOTO :NON_PEAR_INSTALLED)

GOTO PEAR_INSTALLED

:NON_PEAR_INSTALLED
REM Assume php.exe is executable, and that zf.php will reside in the
REM same file as this one
SET PHP_BIN=php.exe
SET PHP_DIR=%c:\xampp\php
GOTO RUN

:PEAR_INSTALLED
REM Assume this was installed via PEAR and use replacements php_bin & php_dir
SET PHP_BIN=@php_bin@
SET PHP_DIR=@php_dir@
GOTO RUN

:RUN
SET ZF_SCRIPT=%PHP_DIR%\zf.php
"%PHP_BIN%" -d safe_mode=Off -f "%ZF_SCRIPT%" -- %*
我认为错误在最后一行的最后一个字符

编辑:原始文件的代码

@ECHO off
REM Zend Framework
REM
REM LICENSE
REM
REM This source file is subject to the new BSD license that is bundled
REM with this package in the file LICENSE.txt.
REM It is also available through the world-wide-web at this URL:
REM http://framework.zend.com/license/new-bsd
REM If you did not receive a copy of the license and are unable to
REM obtain it through the world-wide-web, please send an email
REM to license@zend.com so we can send you a copy immediately.
REM
REM Zend
REM Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
REM http://framework.zend.com/license/new-bsd     New BSD License


REM Test to see if this was installed via pear
SET ZTMPZTMPZTMPZ=@ph
SET TMPZTMPZTMP=%ZTMPZTMPZTMPZ%p_bin@
REM below @php_bin@
FOR %%x IN ("@php_bin@") DO (if %%x=="%TMPZTMPZTMP%" GOTO :NON_PEAR_INSTALLED)

GOTO PEAR_INSTALLED

:NON_PEAR_INSTALLED
REM Assume php.exe is executable, and that zf.php will reside in the
REM same file as this one
SET PHP_BIN=php.exe
SET PHP_DIR=%~dp0
GOTO RUN

:PEAR_INSTALLED
REM Assume this was installed via PEAR and use replacements php_bin & php_dir
SET PHP_BIN=@php_bin@
SET PHP_DIR=@php_dir@
GOTO RUN

:RUN
SET ZF_SCRIPT=%PHP_DIR%\zf.php
"%PHP_BIN%" -d safe_mode=Off -f "%ZF_SCRIPT%" -- %*
编辑:一个命令生成的错误快照

在修改后的代码中更改此行:

SET PHP_DIR=%c:\xampp\php
为此:

SET "PHP_DIR=c:\xampp\php"
Edit-我刚刚意识到,解析器已经去掉了原始修改中额外的%了,所以上面的建议帮不上忙。


将最后一行还原为其原始形式,结尾为%*这应扩展到所有命令行参数。但这对你不起作用。要找出原因,请在还原的最后一行之前添加一行新的
ECHO ON


现在运行脚本并查看如何解释最后一行。如果您无法找出它不起作用的原因,请发布结果。

如果有人能够解决,我将非常感谢他……如果您还显示原始.BAT文件的样子,我可能能够找到如何修复它。嗯?--你说你修改了BAT文件。我需要知道你做了什么改变。这就是为什么在您进行更改之前我要求提供一份文件副本。我只找到了一个解决方案,但不是很好,也不是很好扩展。我们可以用它替换最后一行,以接受命令行中“zf.php”文件最多5个参数。“%PHP_BIN%”-d safe_mode=Off-f“%ZF_SCRIPT%”--%1%2%3%4%5查看我的扩展答案。它可能有助于诊断%*不起作用的原因。我得到以下输出:“php.exe”-d safe_mode=Off-f“c:\xampp\php\zf.php”-*发生错误操作“*”不是有效操作。使用我的方法,即%1%2%3。。。而不是%*满足了我在netbeans中创建zend项目树结构的需要。所以,现在没有问题了。@user950146-非常奇怪。%*在我的机器上工作(当然,由于我没有安装软件,%*会正确扩展,所以命令会失败)。得到结果的唯一方法是在最后一行末尾添加一个介于%和*之间的空格。