I want to run batch file using Java. That batch file doesn't require any arguments. But on running it asks to press enter key twice.
How can I do this using Java code?
This is what I have tried in batch. If I can do this in batch that will also work instead of Java
@if (@CodeSection == @Batch) @then
@echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=C:\Windows\System32\CScript //nologo //E:JScript "%~F0"
rem Start the other program in the same Window
start "" /B test.bat
%SendKeys% "{ENTER}"
%SendKeys% "exit{ENTER}"
goto :EOF
@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
This test.bat
run for some time then asks for key press.