dsjbest2014 2017-10-15 18:06
浏览 147
已采纳

将参数从delphi传递到bat文件,从bat传递到php

I use the code below to pass these three parameters from delphi to the bat file:

CommandLine := Format('cmd.exe /c "d:un.bat %s"', [Email, StartDate, EndDate]);

The run.bat file itself contains:

@echo off
cls
D:
cd \test
"C:\PHP\php.exe" index.php %3

What I am trying to do is to call a bat file from Delphi and pass three parameters. The bat file itself executes a php file to which I need to pass this three parameters and access them via $argv. Using this code I am not able to do this. Can you help me to point out what am I doing wrong?

  • 写回答

1条回答 默认 最新

  • douquanhui5735 2017-10-15 18:13
    关注

    If you want to pass around three parameters, they should all appear on both the producing and the consuming side, like this:

    CommandLine := Format('cmd.exe /c "d:un.bat %s %s %s"', [Email, StartDate, EndDate]);
    

    (assuming that StartDate and EndDate are strings, adapt accordingly if needed) and in the batchfile

    @echo off
    cls
    D:
    cd \test
    "C:\PHP\php.exe" index.php %1 %2 %3
    

    Where %1 means "the first command line parameter", %2 "the second", and so on.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏