If you really look for in simple Windows batch solution, here is one derived from the batch from PostgreSQL.
SET path=c:\
SET /P path="Path of code [%path%]: "
SET folder=\
SET /P folder="Folder name [%folder%]: "
REM and do what you want with those values ...
echo %path%
echo %folder%
This method allows even to propose default values.
EDIT
I've just seen you java code was reading from the console and not from stdin, so no redirection solution will help. Maybe you should look at the following post from SO How to simulate keyboard presses in java?
EDIT2
So the problem was not as I first thought to ask parameters in batch, but to automate a java program that asked two parameters on the console. Robot is a nice trick to automate such things. I wrote a piece of java that simulates its arguments being typed on keyboard followed by enter. My own trick is the use of Alt xyz to send the correct KeyEvent for any character.
You should only do java -jar ...\RoboSend.jar "ext.bat" "real_path" "real_folder"
or java -jar ...\RoboSend.jar "ext.bat" %path% %folder%
package org.sba.robotsend;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
/**
* This program simulates the typing of its arguments on Console keyboard.
* Each argument is send via Robot to the console, followed by an Enter key
* Ex : java -j RobotSend.jar "echo foo" "echo bar" gives :
* c:\> echo foo
* foo
* c:\> echo bar
* bar
*
* It is intented to automate programs reading their input on the Console
*
* @author serge.ballesta
*/
public class RobotSend {
private Robot robot;
private Charset cp850;
private static final int[] keys = { KeyEvent.VK_NUMPAD0, KeyEvent.VK_NUMPAD1,
KeyEvent.VK_NUMPAD2, KeyEvent.VK_NUMPAD3, KeyEvent.VK_NUMPAD4,
KeyEvent.VK_NUMPAD5, KeyEvent.VK_NUMPAD6, KeyEvent.VK_NUMPAD7,
KeyEvent.VK_NUMPAD8, KeyEvent.VK_NUMPAD9
};
/**
* This program simulates the typing of its arguments on Console keyboard.
* Each argument is send via Robot to the console, followed by an Enter key
* Ex : java -j RobotSend.jar "echo foo" "echo bar" gives :
* c:\> echo foo
* foo
* c:\> echo bar
* bar
*
* It is intented to automate programs reading their input on the Console
* @param args the command line arguments
*/
public static void main(String[] args) {
RobotSend robot = new RobotSend();
try {
robot.run(args);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void run(String[] args) throws AWTException {
robot = new Robot();
cp850 = Charset.forName("IBM850");
for (String str: args) {
sendString(str);
}
}
/**
* Send a byte using the Alt xyz sequence.
* the byte must be in CP850 code page, indipendently of the actual code
* page of the console (at least for System natively in CP850 ...)
* @param c the byte (char) to be inputted via keyboard
*/
public void sendByte(byte c) {
int i = (int) c;
if (i < 0) { i = 256 + i; }
if (i < 0 || i > 255) { i = 'X'; }
int i1 = i / 100;
int i2 = (i % 100) / 10;
int i3 = i % 10;
robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(keys[i1]);
robot.keyRelease(keys[i1]);
robot.keyPress(keys[i2]);
robot.keyRelease(keys[i2]);
robot.keyPress(keys[i3]);
robot.keyRelease(keys[i3]);
robot.keyRelease(KeyEvent.VK_ALT);
}
/**
* Simulate a Enter
*/
public void sendEnter() {
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}
/**
* Send a String via the Console keyboard.
* The string is first encoded in CP850, sent one char at a time via sendByte
* and followed by an Enter key
* @param str
*/
public void sendString(String str) {
ByteBuffer buf = cp850.encode(str);
for (byte b: buf.array()) {
sendByte(b);
}
sendEnter();
}
}