将传递的参数重定向到 Windows 批处理文件 [英] Redirecting passed arguments to a windows batch file

查看:24
本文介绍了将传递的参数重定向到 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆