【问题标题】:Running exe with parameters using batch使用批处理运行带有参数的exe
【发布时间】:2015-08-21 23:23:21
【问题描述】:

如何将参数传递到运行 exe 的批处理文件中?我有一个需要 2 个参数的程序,我想使用带有定义参数的 bat 文件运行它 5 次。类似的东西:

FOR /L %%G IN (1,1,5) DO start "path" program.exe -20 -15

其中 20 和 15 是参数。 20 和 15 不识别,怎么定义呢?

【问题讨论】:

  • program.exe -20 -15 在命令提示符下工作吗?
  • 很遗憾没有。所以有问题。我有 c++ 程序,用户需要在其中插入两个数字。我认为它会这样工作

标签: batch-file


【解决方案1】:

如果您的program.exe 接受命令行参数,请使用program.exe 20 15 发送参数2015,或使用program.exe -20 -15 发送参数-20-15

如果"path" 代表program.exe部分或完整路径

 start "" "path\program.exe" 20 15

如果"path" 应该代表program.exe工作目录

 start "" /D "path" program.exe 20 15

阅读start command 文档以通过兼性[options] 以下列语法模式进行进一步修改:

 START "title" [/D path] [options] "command" [parameters]

【讨论】:

    【解决方案2】:

    根据您的评论,您不使用参数,而是使用程序输入。那完全是另一回事了。试试:

    FOR /L %%G IN (1,1,5) DO (echo 20 & echo 15)|program.exe
    

    【讨论】:

      猜你喜欢
      • 2014-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-03
      • 2014-04-22
      • 1970-01-01
      相关资源
      最近更新 更多