What i need: To send "enter" key when batch is still processing a previous line.
I am trying to use batch to have an .exe run through a series of input files. The batch file below runs a program, creates an output file, copies it, and then cleans the folder to run through the next set of input variables.
The problem is that after running the .exe, it says "press enter to continue".
@if (@CodeSection == @Batch) @then
set SendKeys=CScript //nologo //E:JScript "%~F0"
for %%i IN (1,2,3) do (
mpiexec --ppn 20 myprogram "input%%i.input"
%SendKeys% "{ENTER}"
xcopy "D:\Original\input%%i-*" "D:\Output\output%%i-*"
clean.bat
)
pause
goto :EOF
@end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
What ive attempted:
- Use sendkeys after "myprogram", Result: Program still requires enter.
- Use sendkeys before "myprogram", Result: Program still requires enter.
- Use sendkeys in conjunction with 'ping'. The delay happens before or after program, so isnt usefull.
- Attempted to 'pipe' in the sendkeys command. Got an error.
Thoughts?
CALL clean.bat; then control will return to just after the initial CALL statement.. 2. Use%SendKeys% "{ENTER}"beforempiexec. 3. Consider addingWScript.Sleep(100);in the JScript section ; the interval (in milliseconds) to sleep could depend on actual timing. – JosefZ May 31 '19 at 19:29%SendKeys% "{ENTER}" mpiexec --ppn 20 myprogram "input%%i.input" xcopy "D:\Original\input%%i-" "D:\Output\output%%i-" CALL clean.bat )
Ive also added the sleep command. The problem is that it is waiting, and then executing MPIexec. Not executing MPIexc and then doing sendkeys
– Shane_Wilson009 May 31 '19 at 19:38mpiexec(I suppose it's an executable as well) and can't mimic that 15 seconds… Do come the"press enter to continue"request frommpiexecor frommyprogram? – JosefZ May 31 '19 at 20:58echo. | myprogram argsto see whether that bypasses the "press enter to continue" prompt? – Harry Johnston May 31 '19 at 23:22mpiexecasynchronously in their own window, something likestart "input%%i.input" mpiexec --ppn 20 myprogram "input%%i.input" & >NUL TIMEOUT 15 /nobreak & %SendKeys% "{ENTER}" "input%%i.input"where the JScript section should change asWshShell.AppActivate(WScript.Arguments(1)); WScript.Sleep(100); WshShell.SendKeys(WScript.Arguments(0));– JosefZ Jun 01 '19 at 14:08echo. | myprogramworks. However, im having some issues getting it to work with MPIexec, for exampleecho. | mpiexec --ppn 20 myprogram argsdoes not.. Is there anyway to use this technique within the context of the MPI program calling myprogram? – Shane_Wilson009 Jun 03 '19 at 14:59