Reputation: 584
I've got a Java program that takes parameters such as "-range=1-5 -message=Hello".
I've a written a .bat file to launch that java program with a specific jre and some preset parameters. I would like to be able to launch the .bat file with some extra parameters to be added to the java program.
the myexe.bat file is
echo on
rem Force 32 bit Java
"C:\Program Files (x86)\Java\jdk1.8.0_162\bin\java.exe" -jar myexe.jar -param1="value1" %1 %2 %3 %4 %5 %6 %7 %8 %9
I'm expecting that calling
myexe.bat -param2=value2
would lead to
.. -jar myexe.jar -param1="value1" -param2=value2
Instead it's leading to
.. -jar myexe.jar -param1="value1" -param2 value2
Which is wrongly interpreted by the java program.
Surrounding by quotes such as in
.. -jar myexe.jar -param1="value1" "-param2=value2"
Instead it's leading to
.. -jar myexe.jar -param1="value1" "-param2=value2"
Which is also wrongly interpreted by the java program.
Is there a way in the .bat file to use its arguments exactly as they were set ?
Upvotes: 0
Views: 121
Reputation: 10931
%*
is usually the simplest solution here. E.g. this batch file:
echo %1 %2 %3
echo %*
Produces this output:
>mybat.bat -param2=value2
>echo -param2 value2
-param2 value2
>echo -param2=value2
-param2=value2
Upvotes: 2