使用传递到当前正在执行的批处理文件的参数调用另一个程序 [英] Call another program with arguments passed to the currently executing batch file
问题描述
我的用例:有一个repl可执行文件 scala.bat
,它带有一些参数,其中之一允许将其指向启动时运行的配置文件.我将 scala.bat
重命名为 scala-original.bat
,并从 scala.bat
scala-original.bat >:
My use case: having a repl executable scala.bat
which takes some arguments, one of which allows pointing it to a configuration file which is ran on start. I renamed scala.bat
to scala-original.bat
and called scala-original.bat
from inside scala.bat
:
@echo off
scala-original.bat -i C:\Progra~2\scala\bin\test-config.scala
如何将原始参数 scala.bat
传递给 scala-original.bat
?它们应添加在以下内容的末尾:
How can I pass the original arguments scala.bat
was called with to scala-original.bat
? They should be added at the end of:
scala-original.bat -i C:\Progra~2\scala\bin\test-config.scala
例如,调用:
scala.bat -nc
应运行:
scala-original.bat -i C:\Progra~2\scala\bin\test-config.scala -nc
我们现在可以忽略再次指定-i部分的重复.
We can ignore double specifying the -i part again for now.
对于我的用例,使用别名也可能是一种解决方案,如 https://stackoverflow.com/a/21040825/750216 ,例如:
For my use case, using an alias could also be a solution as seen in https://stackoverflow.com/a/21040825/750216 , eg.:
@echo off
doskey scala=scala-original.bat -i C:\Progra~2\scala\bin\test-config.scala $*
推荐答案
%*
是给我的所有参数(当前正在运行的批处理文件)".(尝试在批处理文件中使用 echo%*
).这样可以很容易地将它们传递到下一个批处理文件:
%*
is "all parameters to me (the currently running batchfile)". (Try echo %*
in a batchfile). That makes it very easy to pass them to the next batchfile:
scala-original.bat -i C:\Progra~2\scala\bin\test-config.scala %*
这篇关于使用传递到当前正在执行的批处理文件的参数调用另一个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!