批处理文件错误句柄

时间:2015-11-02 00:35:47

标签: php windows batch-file command-line parameter-passing

我有批处理文件,执行我的PHP脚本,但我不知道如何处理空参数,你能帮帮我吗?

这是我的批处理脚本

echo off
set phppath=%1
set resultfolder=%2
set jsonfile=%3
shift
shift
shift

set PHP_HOME=%phppath%
set PATH=%PATH%;%PHP_HOME%
echo Set PHP_HOME in "%phppath%"
echo Locate result in folder "%resultfolder%"
echo JSON file is "%jsonfile%"


pause;
php -f cxense_json_to_xml.php %resultfolder% %jsonfile%

1 个答案:

答案 0 :(得分:0)

@echo off
set phppath=%1
set resultfolder=%2
set jsonfile=%3
set PHP_HOME=%phppath%
set PATH=%PATH%;%PHP_HOME%
echo Set PHP_HOME in "%phppath%"
echo Locate result in folder "%resultfolder%"
echo JSON file is "%jsonfile%"
php -f cxense_json_to_xml.php %resultfolder% %jsonfile%
Pause

并且必须像这样开始批处理:

Batch.bat "path to PHP" "path to result folder" "name of jsonfile"

暂停后没有分号。