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.

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

报告相同问题?

悬赏问题

  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)