简体   繁体   English

如何以交互方式从批处理文件到jar文件输入参数?

[英]How to enter parameters in an interactive way from batch file to jar file?

I want to run a jar file from batch file and then after running this jar file it will start asking some question for example it will ask about inserting working directory and after inserting the working directory it will ask about the name of file it should look for in this working directory and in the next step it will ask about the method of processing this file and ... 我想从批处理文件运行一个jar文件,然后在运行此jar文件后,它将开始询问一些问题,例如,它将询问有关插入工作目录的信息,并且在插入工作目录后,它将询问有关文件名称的信息在此工作目录中,在下一步中,它将询问有关处理此文件的方法并...

I have written this code in my .bat file 我已将此代码写入.bat文件中

@echo off
set "workingdirectory=C:\MyResult"
set "filename=result.txt"
set "processingmethod=methodD"
cd C:\JavaFolder
java -jar myjavacode.jar "%workingdirectory% %filename% %methodD%

but these steps just run the jar file but they don't pass the arguments needed for going to the next steps. 但是这些步骤仅运行jar文件,但没有传递进行下一步所需的参数。

My question is that is there any way to do all these steps automatically by the use of bat file? 我的问题是,有什么办法可以通过使用bat文件来自动执行所有这些步骤?

您可以使用set / p读取用户的输入:

SET /P "workingdirectory=Please enter working directory"
@echo off 
set /p workingdirectory=Enter working dir
set /p filename=Enter file name
set /p processingmethod=Enter processing method
cd C:\JavaFolder java -jar myjavacode.jar %workingdirectory% %filename% %processingmethod%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM