批处理文件错误句柄

问题描述 投票:0回答:1

我有批处理文件,执行我的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%
php windows batch-file command-line parameter-passing
1个回答
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"

暂停后没有分号。

© www.soinside.com 2019 - 2024. All rights reserved.