It is dumb but should work... What my idea is that you just place other code in your batch file telling it to actually type it into the window. This is usually done with SendKeys. More on the Keys here.
So this would be the script:
@if (@CodeSection == @Batch) @then
@echo off
start "C:\Program Files\Java\jdk1.8.0_101\db\bin\ij.bat"
set SendKeys=CScript //nologo //E:JScript "%~f0"
timeout /t 3
%SendKeys% "run 'setup.sql'"
%SendKeys% "{ENTER}"
Goto:eof
@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
Looks massive but is rather harmless ;)
@if (@CodeSection == @Batch) @then
and
@end
are required to seperate the batch-script from the magic that types keys; the JScript.
@echo off
will simply block any output that the batch file would print for every command.
The next line starts your batch-file that itself starts another command-line application.
Setting the variable SendKeys
is not 100% required but makes it easier to read and it saves the string to activate the JScript-Section (-> Keystroke simulation) to make it easier to use.
Change the timeout value based on your needs. I do not know how long it takes for ij to start.
The next line will stupidly write the command character for character (no worries... You will see nothing!).
Goto:eof
is required to stop the batch-script before reading through the JScript and throwing errors all over.
I am not 100% sure as I do not have tested it but you might need to start your batch-file over the command-line itself like this:
start /min <your batch-file here>
This will start the file minimized to make sure it will type in the correct window.
Feel free to ask questions!