Hello,
I want to create java application which can run .cmd file. I already write the code which run .cmd file, but my problem is the following:
this .cmd file prompts the user to enter his mail and password & I want my program to give these values to the .cmd file & don't take them from user. Is it possible?
the code as the following:
String[] command =
{
"cmd",
};
Process p;
try {
p = Runtime.getRuntime().exec(command);
new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
PrintWriter stdin = new PrintWriter(p.getOutputStream());
stdin.println("appcfg.cmd --no_cookies update ..\\HelloGAE\\war");
stdin.println("ehossny@xxx.com");// email
stdin.println("xxxx"); //password
stdin.flush();
// write any other commands you want here
stdin.close();
int returnCode;
returnCode = p.waitFor();
System.out.println("Return code = " + returnCode);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}