将传递的参数重定向到Windows批处理文件 [英] Redirecting passed arguments to a windows batch file
本文介绍了将传递的参数重定向到Windows批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从Windows批处理文件中调用jar文件.一个要求是能够按原样将所有批处理文件参数传递给jar文件调用.例如,
I would like to call a jar file from a windows batch file. One requirement is to be able to pass all the batch file arguments as-is to the jar file invocation. For example,
必需的命令行:
foo.bat --flag1=x --flag2=y --flag3=z
批处理文件foo.bat
应该如下所示调用foo.jar
:
The batch file foo.bat
should invoke foo.jar
like follows:
java -jar foo.jar --flag1=x --flag2=y --flag3=z
如何使批处理文件执行此操作?
我可以用%来做一些批处理变量魔术,但是这样做有更简单的方法吗?
How do I make the batch file do this?
I can do some batch variable magic with % to do this, but is there a simpler way to do this?
推荐答案
是
java -jar foo.jar %*
满足您的需求?它将批处理执行中的所有参数添加到批处理文件中的应用程序调用中.
meet your needs? It should add all parameters from the batch execution to your application call within the batch file.
这篇关于将传递的参数重定向到Windows批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文